This tries to fix a number of related issues:
* the blurred thumbnail was visible for a split-second sometimes
when switching back to an already-loaded image. (Presumably when
JS was sluggish enough to take more than 10 ms to execute.) We
now check whether the promise is pending before showing a placeholder.
(More generally, a lot of unnecessary logic was executed when paging
through already loaded images, like displaying the placeholder, so
this might make the UI a bit more responsive.)
* the blur could get stuck sometimes - I have seen this a few times,
but have never been able to reproduce it, so I'm only guessing, but
maybe the timing was really unfortunate, and we switched back less
than 10 ms before loading finished. We now remove the blur on every
branch, just to be sure.
* adding a progress handler to a promise might not have any immediate
effect, so when switching to an image which was loading, the progress
bar reacted too late. We now store the progress state per thumbnail
so it is always available immediately.
* the progress would animate from 0 to its actual state whenever we
navigated to the image. The change on paging is now instant; the
progress bar only animates when we are looking at it.
* switching quickly back and forthe between a loaded and a loading
image resulted in the loading image becoming unblurred. This seems
fixed now, I'm not sure why. Maybe the "skip on non-pending promise"
logic affects it somehow.
Also removes some unused things / renames some things which were
confusing, and makes an unrelated fix in the image provider, which kept
amassing fail handlers.
Change-Id: I580becff246f197ec1bc65e82acd422620e35578
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/489
- this avoids an issue where the arrow wouldn't point to what we
want when near the edge of the screen
- this avoids an RTL issue where the bubble would go outside of
the screen
Bug: 64258
Change-Id: I1cc9683af2743b093a45b19d7142fe7e5e66423f
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/485
The code to replay clicks and clean up the handler was called after
processing each thumbnail, instead of just once at the end.
This might have caused many subtle issues such as clicks on any
but the first image not replaying correctly; more problematically,
of there were no MediaViewer-compatible thumbs, the handler was
never cleaned up and the clicks were never replayed.
Besides fixing that, this commit also adds a try..finally wrapper
so that the click replaying is not broken even if there is an error
in the thumb processing code. This might or might not be a good
idea. The internets say that try..finally without a catch causes
errors in IE8, but only if it is not wrapped in another try..catch,
so we are probably fine. (Adding a catch which just rethrows the
error would be an alternative, but it messes up stack traces.)
Change-Id: I2f645762103274c92c15a0d4b595d18d93b08415
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/497
Bug: 64345
With latest refactorings, the animatin looked like a glitch.
The position of the panel has been adjusted to (a) make the initial
position the same as shown while the progress bar for better continuity,
and (b) make the move more noticeable by increasing the distance the
panel moves.
To test, clear the local storage variable mmv.hasOpenedMetadata
Change-Id: Ie3ed29826fa15bf4c6b38f0fc8bde4bd84563fb9