apply css animation to specific html element using angularjs -
please check first demo on plnkr.
my problem is: animation applied elements in html, cause in css defined .ng-enter .ng-leave etc.
i trying apply specific class name. in case, it's <li class="specific">
and in css i've tried following:
.specific.ng-enter /*(does not work)*/ .specific-ng-enter /*(does not work)*/
with these code above, can add , remove items without animation.
how should code in css ?
actually, there couple of possible issues code:
you using
ngrepeat
on<ul>
(i cannot 100% sure not want highly improbable).ngrepeat
"repeat" (clone" element on, in case creating multiple<ul>
elements (instead of multiple<li>
elements, 1 expect).
movingngrepeat
o<li>
solve animation problem , result in intended html code (1<ul>
, multiple<li>
).your css defined transition every class, while suffice define 1 rule:
.top.ng-enter, .top.ng-leave { // ...define transitions here }
in order avoid possible css specificity issues (especially later on, when css grows in size , complexity), should include
.ng-enter/leave
class selector in rules.ng-*-active
:// instead of just: .top.ng-enter-active {...
// should use: .top.ng-enter.enter-active {...
finally, can group identical rules together, save space , make code more dry (e.g.
.top.ng-enter
rule ===.top.ngleave.ng-leave-active
rule).
your final code should this:
<!-- html --> <ul> <li class="top" ng-repeat="item in items">{{item}}</li> </ul> /* css */ .top.ng-enter, .top.ng-leave { -webkit-transition: 1s; transition: 1s; } .top.ng-enter, .top.ng-leave.ng-leave-active { margin-left: 100%; } .top.ng-enter.ng-enter-active, .top.ng-leave { margin-left: 0; }
see, also, short demo.
Comments
Post a Comment