English 中文(简体)
CSS3 过渡活动
原标题:CSS3 transition events

是否有一分子发射任何事件来检查三轮驱动器是否已经启动或结束?

最佳回答

W3C CSS Transitions Draft

完成科索沃安全局的过渡会产生相应的索马里行动。 每一不动产都受到攻击。 这使得内容编制者能够开展与完成过渡同步的行动。


Webkit

为了确定过渡何时完成,为过渡阶段结束时发出的“OM”活动设置了“Java”诗歌听器功能。 这项活动是WebKit TransitionEvent的一个实例,其类型为webkit TransitionEnd

box.addEventListener(  webkitTransitionEnd , 
    function( event ) { alert( "Finished transition!" ); }, false );

Mozilla

过渡时期结束后,发生了一起事件。 活动名称:transend,操作,o Transition End , and in Web 页: 1

Opera

There is one type of transition event available. The oTransitionEnd event occurs at the completion of the transition.

Internet Explorer

<代码>过渡活动在过渡完成时发生。 如果过渡工作在完成之前结束,则不会发生火灾。


超支: 我如何使CSS3过渡职能在整个浏览器中实现正常化?

问题回答

<>Update>

所有现代浏览器现在都支持未预定的活动:

element.addEventListener ( transitionend , callsback, false);

https://caniuse.com/#feat=cs-transitions”rel=“noreferer”>https://caniuse.com/#feat=cs-transitions


我采用佩特的做法,但我现在开始采用以下做法:

$(".myClass").one( transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd , 
function() {
 //do something
});

或者,如果你使用boot,那么你就能够干 do。

$(".myClass").one($.support.transition.end,
function() {
 //do something
});

这包括boot锁中的以下部分。 j)

+function ($) {
   use strict ;

  // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  // ============================================================

  function transitionEnd() {
    var el = document.createElement( bootstrap )

    var transEndEventNames = {
       WebkitTransition  :  webkitTransitionEnd ,
       MozTransition     :  transitionend ,
       OTransition       :  oTransitionEnd otransitionend ,
       transition        :  transitionend 
    }

    for (var name in transEndEventNames) {
      if (el.style[name] !== undefined) {
        return { end: transEndEventNames[name] }
      }
    }

    return false // explicit for ie8 (  ._.)
  }


  $(function () {
    $.support.transition = transitionEnd()
  })

}(jQuery);

说明中还包括一种可确保总是出现退约所需的良机。

  // http://blog.alexmaccaw.com/css-transitions
  $.fn.emulateTransitionEnd = function (duration) {
    var called = false, $el = this
    $(this).one($.support.transition.end, function () { called = true })
    var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
    setTimeout(callback, duration)
    return this
  }

Be aware that sometimes this event doesn’t fire, usually in the case when properties don’t change or a paint isn’t triggered. To ensure we always get a callback, let’s set a timeout that’ll trigger the event manually.

http://blog.alexmaccaw.com/cs-transitions

http://caniuse.com/#feat=css-transitions”

element.addEventListener ( transitionend , callsback, false);

最新版本的“ Chrome”、“ Firefox”和“Sato”工程。 甚至IE10+。

在操作12时,如果你要使用简便的 Java本,转播工作将:

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

然而,如果你通过 j子约束,你需要使用 o。

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

如果有的话,你正在使用现代仪或boot子进行过滤。 j 您只能作一改动:

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

http://www.ianlunn.co.uk/blog/articles/opera-12-otransitionend-bugs-and-workarounds/“rel=noreferer” http://www.ianlunn.co.uk/blog/articles/opera-12-otransitionend-bugs-and-workarounds/。

就真的,不这样做!

$.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 );
});

如果你只想发现一个单一的过渡目的,而在此不使用任何联合材料框架,则这种功能便捷:

function once = function(object,event,callback){
    var handle={};

    var eventNames=event.split(" ");

    var cbWrapper=function(){
        eventNames.forEach(function(e){
            object.removeEventListener(e,cbWrapper, false );
        });
        callback.apply(this,arguments);
    };

    eventNames.forEach(function(e){
        object.addEventListener(e,cbWrapper,false);
    });

    handle.cancel=function(){
        eventNames.forEach(function(e){
            object.removeEventListener(e,cbWrapper, false );
        });
    };

    return handle;
};

使用:

var handler = once(document.querySelector( #myElement ),  transitionend , function(){
   //do something
});

如果你希望在某个时候取消,你仍然可以这样做。

handler.cancel();

它对其他活动使用也有好处:





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签