1 line
1.4 KiB
JSON
1 line
1.4 KiB
JSON
{"ast":null,"code":"import canUseDOM from './canUseDOM';\nimport css from './css';\nimport listen from './listen';\nexport var TRANSITION_SUPPORTED = canUseDOM && 'ontransitionend' in window;\nexport function parseDuration(node) {\n var str = css(node, 'transitionDuration') || '';\n var mult = str.indexOf('ms') === -1 ? 1000 : 1;\n return parseFloat(str) * mult;\n}\n\nfunction triggerTransitionEnd(element) {\n var evt = document.createEvent('HTMLEvents');\n evt.initEvent('transitionend', true, true);\n element.dispatchEvent(evt);\n}\n\nexport function emulateTransitionEnd(element, duration, padding) {\n if (padding === void 0) {\n padding = 5;\n }\n\n var called = false;\n var handle = setTimeout(function () {\n if (!called) triggerTransitionEnd(element);\n }, duration + padding);\n var remove = listen(element, 'transitionend', function () {\n called = true;\n }, {\n once: true\n });\n return function () {\n clearTimeout(handle);\n remove();\n };\n}\n\nfunction transitionEnd(element, handler, duration) {\n if (!TRANSITION_SUPPORTED) {\n return emulateTransitionEnd(element, 0, 0);\n }\n\n if (duration == null) duration = parseDuration(element) || 0;\n emulateTransitionEnd(element, duration);\n return listen(element, 'transitionend', handler);\n}\n\nexport default transitionEnd;","map":null,"metadata":{},"sourceType":"module"} |