Loading indicator
This is a proposed implementation of one of the features on the wishlist. Some notes:
- The spinner is implemented as an animated gif, which I took from the PDF.js example viewer
- It's embedded in the JS source as a base64-encoded data url.
- To center the spinner on each page DOM element, I set the
positionstyle attribute of the.plv-page-container.page-containerdivsasrelative. That might cause problems when integratingpdfListViewon an already styled page. A possible alternative is to setposition: absoluteon the loading indicator and calculate its position withPageView.getCanvasPositionInViewer.
Feel free to merge :)
@jazzido, thanks for proposing this PR. This is definitely a feature worth adding. However, I don't think the PR is good to be merged the way it is at the moment.
My main concern is, that I want the pdfListViewer to be "flexible, modular, easy to replace parts with other implementations". This is not really given with your implementation, as the spinner is hard coded ;)
The way the textLayer and annotationLayer are integrated is already flexible to some extend. Maybe it's worth adding a bit of infrastructure to add support for spinners as well. Here is what I think:
- add a event library to pdfListView, such that object (e.g.
PageViewcan emit and listen to event)
- choose a library that allows to bubble events up to an object's parent (e.g. an event dispatched on the PageView should dispatch it on the listView it is owned by)
2) emit event like
render-setp-context,render-begin,render-doneetc. on thepageView3) make the textLayer, annotationLayer listen to these events 4) implement a new "spinner" object also by listening to these events
@jazzido, do you see where I am heading? Let me know what you think. If you want I can do steps 1)-3) from above and then leave the stage for you to do 4)?
@jazzido, do you see where I am heading? Let me know what you think. If you want I can do steps 1)-3) from above and then leave the stage for you to do 4)?
That sounds about right. Adding an event library to pdfListView would require substantial changes so I'd better leave that to you. I'll be happy to hook a spinner when that's done.
Thanks!