1 | import css from 'dom-helpers/css';
|
2 | import transitionEnd from 'dom-helpers/transitionEnd';
|
3 | function parseDuration(node, property) {
|
4 | const str = css(node, property) || '';
|
5 | const mult = str.indexOf('ms') === -1 ? 1000 : 1;
|
6 | return parseFloat(str) * mult;
|
7 | }
|
8 | export default function transitionEndListener(element, handler) {
|
9 | const duration = parseDuration(element, 'transitionDuration');
|
10 | const delay = parseDuration(element, 'transitionDelay');
|
11 | const remove = transitionEnd(element, e => {
|
12 | if (e.target === element) {
|
13 | remove();
|
14 | handler(e);
|
15 | }
|
16 | }, duration + delay);
|
17 | } |
\ | No newline at end of file |