Browse Source

Emulate transition end event

pull/782/head
Johann-S 10 years ago
parent
commit
71b6d35be1
  1. 17
      js/common.js
  2. 2
      js/popovers.js
  3. 6
      js/push.js

17
js/common.js

@ -54,4 +54,21 @@
return transEndEventNames.transition;
})();
window.RATCHET.emulateTransitionEnd = function (duration, target) {
var called = false;
target.addEventListener(window.RATCHET.getTransitionEnd, function () {
called = true;
});
var callback = function () {
if (!called) {
var e = new CustomEvent(window.RATCHET.getTransitionEnd, {
bubbles: true,
cancelable: true
});
target.dispatchEvent(e);
}
};
setTimeout(callback, duration);
};
}());

2
js/popovers.js

@ -10,6 +10,7 @@
'use strict';
var popover;
var popoverDuration = 250;
var findPopovers = function (target) {
var i;
@ -36,6 +37,7 @@
element.addEventListener('touchend', function () {
popover.addEventListener(window.RATCHET.getTransitionEnd, onPopoverHidden);
window.RATCHET.emulateTransitionEnd(popoverDuration, popover);
popover.classList.remove('visible');
popover.parentNode.removeChild(backdrop);
});

6
js/push.js

@ -13,7 +13,7 @@
'use strict';
var noop = function () {};
var pushDuration = 400;
// Pushstate caching
// ==================
@ -383,6 +383,7 @@
container.removeEventListener(window.RATCHET.getTransitionEnd, fadeContainerEnd);
swap.classList.add('in');
swap.addEventListener(window.RATCHET.getTransitionEnd, fadeSwapEnd);
window.RATCHET.emulateTransitionEnd(pushDuration, swap);
};
var fadeSwapEnd = function () {
swap.removeEventListener(window.RATCHET.getTransitionEnd, fadeSwapEnd);
@ -394,7 +395,7 @@
}
};
container.addEventListener(window.RATCHET.getTransitionEnd, fadeContainerEnd);
window.RATCHET.emulateTransitionEnd(pushDuration, swap);
}
if (/slide/.test(transition)) {
@ -414,6 +415,7 @@
container.classList.add(containerDirection);
swap.classList.remove(swapDirection);
swap.addEventListener(window.RATCHET.getTransitionEnd, slideEnd);
window.RATCHET.emulateTransitionEnd(pushDuration, swap);
}
};

Loading…
Cancel
Save