CSS3 transition events

前端 未结 6 1569
情歌与酒
情歌与酒 2020-11-22 07:18

Are there any events fired by an element to check wether a css3 transition has started or end?

6条回答
  •  一个人的身影
    2020-11-22 07:51

    In Opera 12 when you bind using the plain JavaScript, 'oTransitionEnd' will work:

    document.addEventListener("oTransitionEnd", function(){
        alert("Transition Ended");
    });
    

    however if you bind through jQuery, you need to use 'otransitionend'

    $(document).bind("otransitionend", function(){
        alert("Transition Ended");
    });
    

    In case you are using Modernizr or bootstrap-transition.js you can simply do a change:

    var transEndEventNames = {
        'WebkitTransition' : 'webkitTransitionEnd',
        'MozTransition'    : 'transitionend',
        'OTransition'      : 'oTransitionEnd otransitionend',
        'msTransition'     : 'MSTransitionEnd',
        'transition'       : 'transitionend'
    },
    transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ];
    

    You can find some info here as well http://www.ianlunn.co.uk/blog/articles/opera-12-otransitionend-bugs-and-workarounds/

提交回复
热议问题