angularjs - Can ngAnimate be used without defining CSS3 classes or JavaScript? -
is possible use nganimate without css3 or javascript? let's if need toggle opacity, can in markup?
<div ng-show='foo == 'yes'' ng-animate="show: 'opacity:1', hide: 'opacity:0'" > </div>
animation in browser either needs happen (1) letting browser's rendering engine handle via css, or (2) controlling javascript. so, somewhere, 1 of these 2 things needs happen.
that said, build own directive builds correct css and/or javascript on fly , attaches/applies given element, believe using nganimate
provided easier.
an example coming nganimate
first time:
html:
<div ng-show="foo == 'yes'" ng-animate="{show: 'fade'}"></div>
css:
.enter-fade { -webkit-transition: 1s linear opacity; -moz-transition: 1s linear opacity; -o-transition: 1s linear opacity; transition: 1s linear opacity; opacity: 0; } .enter-fade.enter-fade-active { opacity: 1; }
or, if you're supporting browsers don't support css3 transitions, can transition javascript instead:
mymodule.animation('fade', function() { return { setup : function(element) { element.css({'opacity': 0}); }, start : function(element, done, memo) { element.animate({'opacity': 1}, function() { done(); }); } }; });
you can find more information @ these great yearofmoo articles:
Comments
Post a Comment