-
Notifications
You must be signed in to change notification settings - Fork 53
Conversation
Also prefetch the previous photo. Add custom fallback prefetching code if HTML5 prefetch not supported.
Delay the prefetching until the current image has finished loading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment.
if (current2x) { | ||
// If the currently displayed image uses the 2x variant, | ||
// chances are that so will the next one. | ||
href = preloadPhoto.medium2x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and no. I think you still need to check if medium2x is not empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that not covered on line 161?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho right. xD
if (current2x) { | ||
// If the currently displayed image uses the 2x variant, | ||
// chances are that so will the next one. | ||
href = preloadPhoto.medium2x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho right. xD
Fixes #129.
The display of the thumbnail in the photo view while the larger-resolution image is being loaded is implemented using CSS background image (on the
<img>
object, no less). It actually looks pretty cool, I think.Image prefetching code was extended to request both previous and next images. The prefetch request is initiated only after the main image has finished loading. We no longer prefetch movie files. There's now a fallback for browsers that don't support HTML5
link rel=prefetch
. While the fallback was trivial, detecting whether it's needed was not. I thought I would be forced to hardcode it based on the user agent, but in the end I found some code that's supposed to detect it at run time.Code was also extended in places to handle the case of previous or next image being empty, to fully support non-wraparound feature being added to the server.