CSS3 transition events

前端 未结 6 1603
情歌与酒
情歌与酒 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:39

    Just for fun, don't do this!

    $.fn.transitiondone = function () {
      return this.each(function () {
        var $this = $(this);
        setTimeout(function () {
          $this.trigger('transitiondone');
        }, (parseFloat($this.css('transitionDelay')) + parseFloat($this.css('transitionDuration'))) * 1000);
      });
    };
    
    
    $('div').on('mousedown', function (e) {
      $(this).addClass('bounce').transitiondone();
    });
    
    $('div').on('transitiondone', function () {
      $(this).removeClass('bounce');
    });
    

提交回复
热议问题