Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter thumbnail scrolling #854

Merged
merged 7 commits into from
Dec 9, 2011
Merged

Conversation

arturadib
Copy link
Contributor

OK hopefully this time the conflicts are fixed... sorry about the repeated requests!

Currently we render all thumbs in series starting from #1, with a 500ms delay, which is pretty much useless for a large document.

This new code renders the thumbs that correspond to the current scroll position in the thumbnail viewer, after the scrolling has paused for some milliseconds. This allows users to scroll to page #1000 and see the thumb almost instantly, without hiccups in the UI.

Also the thumbnail viewer now works in WebKit.

PS: I've noticed that we start throwing some blank pages and errors with intelisa, and it just won't work at all with pdf.pdf. I think these issues are specific to the thumbnail code.

@brendandahl
Copy link
Contributor

Tried it out and it works well. Do you think we could pre-render a few more pages than what are visible so there's a little less lag?

@@ -119,6 +118,7 @@

<div id="loading">Loading... 0%</div>
<div id="viewer"></div>

<script type="text/javascript" src="viewer.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good practice to move the "global" page scripts here.

You can move the initialization sidebarScrollView.addEventListener('scroll', updateThumbViewArea, true); into some event when page loaded, e.g. https://developer.mozilla.org/en/Gecko-Specific_DOM_Events#DOMContentLoaded

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is also https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L630

or

or you can provide the comment why the script load moved here, to avoid other developer moving it back in the header

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good practice to move the "global" page scripts here.

AFAIK there are more pros than cons in keeping scripts at the bottom (progressive rendering, parallel downloads, etc http://developer.yahoo.com/blogs/ydn/posts/2007/07/high_performanc_5/). In our case the additional advantage is that we don't have to bind to DOC-ready or -load.

So I moved the whole thing down.

@notmasteryet
Copy link
Contributor

Since we rendering pages to display thumbs, shall we create full size pages and place them into secondary cache while setting thumbnails, and then re-use those cached images during display?

@arturadib
Copy link
Contributor Author

shall we create full size pages and place them into secondary cache while setting thumbnails, and then re-use those cached images during display?

That sounds like a great idea, but I think it's beyond the scope of the pull.

@notmasteryet
Copy link
Contributor

I'm not comfortable with moving the external script references to the bottom of the html page, that's not where I would expect them. Let's see if other people okay with that.

@arturadib
Copy link
Contributor Author

I'm not comfortable with moving the external script references to the bottom of the html page

I'm reversing the change, and moving the event binding to 'load'. This is not an ideal solution (load waits for things beyond the DOM to load, and DOMContentLoaded is not cross-browser), but I prefer to do this rather than starting yet another discussion about "style".

I've listed the advantages of having the script at the bottom; it's also the recommended practice from just about everywhere I know.

Next time please list the actual reasons why you feel uncomfortable with a change.

@jviereck
Copy link
Contributor

jviereck commented Dec 8, 2011

I like to have the <script> tags in the <head> segment as well. Adding the script tags at the bottom is the best practice for deployment, but leaving the script tags in the head makes the HTML more understandable for me. At the top you see all the files that are "included" on the page (css, js, ...) and later comes the actual HTML markup.

For people coming to the project, they might look at the viewer.html file to get a basic understanding on how things are working. Therefore, I think the viewer.html file should be as simple as possible to understand.

@arturadib, we could mabye add the script tags at the bottom during builds (extension, ...)? As this pull request is about thumbnail rendering, there should be another pull request for doing this script tag change if we agree on doing it.

@arturadib
Copy link
Contributor Author

I had already reversed the changes (cf above), the scripts are already at the head. I'm moving on.

@notmasteryet
Copy link
Contributor

Beautiful. Thank you.

notmasteryet added a commit that referenced this pull request Dec 9, 2011
@notmasteryet notmasteryet merged commit efd82ab into mozilla:master Dec 9, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants