I understand that there is the advantage of not integrating with the $animate service and having a purely class solution.
If you use $animate with addClass and removeClass , but interrupt the animation (for example, quickly and repeatedly click on an element), the animation will be a “jerk” to its end / starting point, and then animate from this position, at least in Chrome. Using pure CSS solutions avoids this problem and always animate the exact current point, providing a smoother effect.
An additional advantage is also a solution, and you do not need a special directive.
For example, HTML may be as follows:
<flip class="{{side === 'front' ? 'flip-front' : 'flip-back'}}"> <flip-front> Front side contents </flip-front> <flip-back> Rear contents </flip-back> </flip>
I use custom elements, but they do not need to have any directives: they are only for CSS:
flip > flip-front, flip > flip-back { -webkit-backface-visibility: hidden; backface-visibility: hidden; transition: -webkit-transform 0.5s; transition: transform 0.5s; } flip > flip-front { -webkit-transform: perspective(800px) rotateY(0); transform: perspective(800px) rotateY(0); } flip > flip-back { -webkit-transform: perspective(800px) rotateY(180deg); transform: perspective(800px) rotateY(180deg); } flip.flip-back > flip-front { -webkit-transform: perspective(800px) rotateY(-180deg); transform: perspective(800px) rotateY(-180deg); } flip.flip-back > flip-back { -webkit-transform: perspective(800px) rotateY(0); transform: perspective(800px) rotateY(0); }
This can be seen in the demo version of http://plnkr.co/edit/A7IeGa1JEsZishmTDTaK?p=preview
source share