summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom <tw201207@gmail.com>2014-11-19 18:41:29 +0100
committerTom <tw201207@gmail.com>2014-11-19 18:41:29 +0100
commitadd899d48daaec9b4df1a0fdcbdd5fc6cce0da0b (patch)
tree667eb3e69eeeeb27a5645f9d8b2834589d029860 /src
parent8f1dc607d135fd99d769a2dfd1e11e00d72d0506 (diff)
downloadgitblit-add899d48daaec9b4df1a0fdcbdd5fc6cce0da0b.tar.gz
gitblit-add899d48daaec9b4df1a0fdcbdd5fc6cce0da0b.zip
Usability bug fix
If the opacity slider was moved to the far right faster than the animation showing the image, the user would never see the old file because opacity got adjusted right away. Now we first move the overlay slider to the right, so that something is visible, and then quickly animate opacity to the current value.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/wicket/pages/scripts/imgdiff.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/scripts/imgdiff.js b/src/main/java/com/gitblit/wicket/pages/scripts/imgdiff.js
index e993997a..61575132 100644
--- a/src/main/java/com/gitblit/wicket/pages/scripts/imgdiff.js
+++ b/src/main/java/com/gitblit/wicket/pages/scripts/imgdiff.js
@@ -167,9 +167,27 @@ function setup() {
overlayAccess.moveAuto(newRatio);
}
});
+
+ var autoShowing = false;
$opacitySlider.on('slider:pos', function(e, data) {
- if ($div.width() <= 0 && !blinking) overlayAccess.moveAuto(1.0); // Make old image visible in a nice way
- $img.css('opacity', 1.0 - data.ratio);
+ if ($div.width() <= 0 && !blinking) {
+ // Make old image visible in a nice way, *then* adjust opacity
+ autoShowing = true;
+ overlayAccess.moveAuto(1.0, 500, function() {
+ $img.stop().animate(
+ {opacity: 1.0 - opacityAccess.getRatio()},
+ {duration: 400,
+ complete: function () {
+ // In case the opacity handle was moved while we were trying to catch up
+ $img.css('opacity', 1.0 - opacityAccess.getRatio());
+ autoShowing = false;
+ }
+ }
+ );
+ });
+ } else if (!autoShowing) {
+ $img.css('opacity', 1.0 - data.ratio);
+ }
});
$opacitySlider.on('click', function(e) {
var newRatio = (e.pageX - $opacitySlider.offset().left) / $opacitySlider.innerWidth();