AngularJS 1.2 Animation fallback when no-cssanimations supported

后端 未结 1 589
被撕碎了的回忆
被撕碎了的回忆 2021-02-10 21:48

I\'m using the new AngularJS 1.2 approach (year of moo article) for animations using CSS3 transitions. I\'d like to conditionally apply a fallback jQuery animation if the browse

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-10 22:40

    You can't use a complex selector like that in your animation() factory method. You can only use a single CSS class name for one level. Instead make your animation factory method conditional based on the browser's capabilities by using $sniffer to detect if you have the transitions there or not.

    //you can make this an EMPTY string if you want this animation to apply to ALL
    //possible elements...
    app.animation('.slideup-form', function($sniffer) {
      if(!$sniffer.transitions) {
        //this object will conditionally be added if the browser doesn't support
        //native CSS3 animations
        return {
          enter             : function(element, done) {},
          leave             : function(element, done) {},
          move              : function(element, done) {},
          beforeAddClass    : function(element, className, done) {},
          addClass          : function(element, className, done) {},
          beforeRemoveClass : function(element, className, done) {},
          removeClass       : function(element, className, done) {}
        }
      }
    });
    

    Just remember to call done() in your JS animation code. Also upgrade to 1.2.5.

    0 讨论(0)
提交回复
热议问题