diff options
author | Sam Potts <sam@potts.es> | 2018-06-13 00:02:55 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-06-13 00:02:55 +1000 |
commit | 392dfd024c505f5ae1bbb2f0d3e0793c251a1f35 (patch) | |
tree | aedb56d3945eaa10bf74e61902e16c08fd24914a /src/js/utils/animation.js | |
parent | 840e31a693462e7ed9f7644a13a0187d9e9d93a9 (diff) | |
download | plyr-392dfd024c505f5ae1bbb2f0d3e0793c251a1f35.tar.lz plyr-392dfd024c505f5ae1bbb2f0d3e0793c251a1f35.tar.xz plyr-392dfd024c505f5ae1bbb2f0d3e0793c251a1f35.zip |
Utils broken down into seperate files and exports
Diffstat (limited to 'src/js/utils/animation.js')
-rw-r--r-- | src/js/utils/animation.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/js/utils/animation.js b/src/js/utils/animation.js new file mode 100644 index 00000000..95e39f03 --- /dev/null +++ b/src/js/utils/animation.js @@ -0,0 +1,30 @@ +// ========================================================================== +// Animation utils +// ========================================================================== + +import { toggleHidden } from './elements'; +import is from './is'; + +export const transitionEndEvent = (() => { + const element = document.createElement('span'); + + const events = { + WebkitTransition: 'webkitTransitionEnd', + MozTransition: 'transitionend', + OTransition: 'oTransitionEnd otransitionend', + transition: 'transitionend', + }; + + const type = Object.keys(events).find(event => element.style[event] !== undefined); + + return is.string(type) ? events[type] : false; +})(); + +// Force repaint of element +export function repaint(element) { + setTimeout(() => { + toggleHidden(element, true); + element.offsetHeight; // eslint-disable-line + toggleHidden(element, false); + }, 0); +} |