diff options
author | Martijn Cuppens <martijn.cuppens@gmail.com> | 2018-03-13 11:59:20 +0300 |
---|---|---|
committer | Johann-S <johann.servoire@gmail.com> | 2018-03-13 11:59:20 +0300 |
commit | 1fadad1c33b99b94a4a821fe5c62c8064d129424 (patch) | |
tree | 8ea41f4bf03696e7718cc7c3e1216b7153b2fc85 /js/src/util.js | |
parent | 1859595cb6e1c92ba8134a7c12a087cb05f89688 (diff) |
Variable transition durations (#25662)
Diffstat (limited to 'js/src/util.js')
-rw-r--r-- | js/src/util.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/util.js b/js/src/util.js index 7e5d5de5c6..05a69977c2 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -17,6 +17,7 @@ const Util = (($) => { let transition = false const MAX_UID = 1000000 + const MILLISECONDS_MULTIPLIER = 1000 // Shoutout AngusCroll (https://goo.gl/pxwQGp) function toType(obj) { @@ -104,6 +105,23 @@ const Util = (($) => { } }, + getTransitionDurationFromElement(element) { + // Get transition-duration of the element + let transitionDuration = $(element).css('transition-duration') + + // Return 0 if element or transition duration is not found + if (!transitionDuration) { + return 0 + } + + // If multiple durations are defined, take the first + transitionDuration = transitionDuration.split(',')[0] + + // jQuery always converts transition durations into seconds, + // so multiply by 1000 + return parseFloat(transitionDuration) * MILLISECONDS_MULTIPLIER + }, + reflow(element) { return element.offsetHeight }, |