React TransitionStart不会触发事件

时间:2019-02-18 10:02:35

标签: reactjs css-transitions react-animations

        componentDidMount(){
                ReactDOM.findDOMNode(this).addEventListener(
transitionEndEventName(), this.onTransitionEnd, false);
                ReactDOM.findDOMNode(this).addEventListener(
transitionStartEventName(),this.onTransitionStart, false);
            }

        function transitionStartEventName () {
            var i,
                undefined,
                el = document.createElement('div'),
                transitions = {
                    'transition':'transitionstart',
                    'OTransition':'otransitionstart',  
    // oTransitionEnd in very old Opera
                    'MozTransition':'transitionstart',
                    'WebkitTransition':'webkitTransitionStart'
                };

            for (i in transitions) {
                if (transitions.hasOwnProperty(i) && el.style[i] !== undefined) {
                    return transitions[i];
                }
            }

            //TODO: throw 'TransitionEnd event is not supported in this browser';
        } 

在Chrome中的onTransitionEnd可以完美运行,但transitionStartEventName尚未启动

0 个答案:

没有答案