Permalink
Browse files

Test that slider setX is actually resulting in movement.

If it is, register the callback as usual to fire when transition
completes. If it isn't, simply defer the callback.

This fixes a pernicious little bug where slowly cancelling a page turn
in the Slider would "lock" the page -- you couldn't turn it again
without a jump.
  • Loading branch information...
joseph committed Dec 25, 2011
1 parent e4527f2 commit 293548ecbc77b0095fda84064f70d5092c9a1aa7
Showing with 13 additions and 1 deletion.
  1. +12 −0 src/core/styles.js
  2. +1 −1 src/flippers/slider.js
View
@@ -60,6 +60,18 @@ Monocle.Styles = {
},
+ getX: function (elem) {
+ var currStyle = document.defaultView.getComputedStyle(elem, null);
+ var re = /matrix\([^,]+,[^,]+,[^,]+,[^,]+,\s*([^,]+),[^\)]+\)/;
+ var props = Monocle.Browser.css.toDOMProps('transform');
+ var matrix = null;
+ while (props.length && !matrix) {
+ matrix = currStyle[props.shift()];
+ }
+ return parseInt(matrix.match(re)[1]);
+ },
+
+
transitionFor: function (elem, prop, duration, timing, delay) {
var tProps = Monocle.Browser.css.toDOMProps('transition');
var pProps = Monocle.Browser.css.toCSSProps(prop);
View
@@ -370,7 +370,7 @@ Monocle.Flippers.Slider = function (reader) {
}
if (typeof callback == "function") {
- if (duration) {
+ if (duration && Monocle.Styles.getX(elem) != x) {
Monocle.Events.afterTransition(elem, callback);
} else {
Monocle.defer(callback);

0 comments on commit 293548e

Please sign in to comment.