Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'js/dist/util.js')
-rw-r--r--js/dist/util.js47
1 files changed, 26 insertions, 21 deletions
diff --git a/js/dist/util.js b/js/dist/util.js
index 0b4963174f..c16c408584 100644
--- a/js/dist/util.js
+++ b/js/dist/util.js
@@ -10,8 +10,9 @@ var Util = function ($) {
* Private TransitionEnd Helpers
* ------------------------------------------------------------------------
*/
- var transition = false;
- var MAX_UID = 1000000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
+ var TRANSITION_END = 'transitionend';
+ var MAX_UID = 1000000;
+ var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
function toType(obj) {
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
@@ -19,8 +20,8 @@ var Util = function ($) {
function getSpecialTransitionEndEvent() {
return {
- bindType: transition.end,
- delegateType: transition.end,
+ bindType: TRANSITION_END,
+ delegateType: TRANSITION_END,
handle: function handle(event) {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
@@ -31,16 +32,6 @@ var Util = function ($) {
};
}
- function transitionEndTest() {
- if (typeof window !== 'undefined' && window.QUnit) {
- return false;
- }
-
- return {
- end: 'transitionend'
- };
- }
-
function transitionEndEmulator(duration) {
var _this = this;
@@ -57,12 +48,8 @@ var Util = function ($) {
}
function setTransitionEndSupport() {
- transition = transitionEndTest();
$.fn.emulateTransitionEnd = transitionEndEmulator;
-
- if (Util.supportsTransitionEnd()) {
- $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
- }
+ $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
}
/**
* --------------------------------------------------------------------------
@@ -95,14 +82,32 @@ var Util = function ($) {
return null;
}
},
+ getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
+ if (!element) {
+ return 0;
+ } // Get transition-duration of the element
+
+
+ var transitionDuration = $(element).css('transition-duration');
+ var floatTransitionDuration = parseFloat(transitionDuration); // Return 0 if element or transition duration is not found
+
+ if (!floatTransitionDuration) {
+ return 0;
+ } // If multiple durations are defined, take the first
+
+
+ transitionDuration = transitionDuration.split(',')[0];
+ return parseFloat(transitionDuration) * MILLISECONDS_MULTIPLIER;
+ },
reflow: function reflow(element) {
return element.offsetHeight;
},
triggerTransitionEnd: function triggerTransitionEnd(element) {
- $(element).trigger(transition.end);
+ $(element).trigger(TRANSITION_END);
},
+ // TODO: Remove in v5
supportsTransitionEnd: function supportsTransitionEnd() {
- return Boolean(transition);
+ return Boolean(TRANSITION_END);
},
isElement: function isElement(obj) {
return (obj[0] || obj).nodeType;