27.03.2017 Views

ng-book

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A<strong>ng</strong>ular Animation 412<br />

CSS3 Animations<br />

Let’s start by addi<strong>ng</strong> the @keyframe animations that we’ll define for the animation. Here, we add a<br />

background color to highlight the text. We also define the remove animation for pulli<strong>ng</strong> the highlight<br />

from the text:<br />

@keyframes animateMe-add {<br />

from {font-size: 16px;}<br />

to {font-size: 50px;}<br />

}<br />

@-webkit-keyframes animateMe-add {<br />

from {font-size: 16px;}<br />

to {font-size: 50px;}<br />

}<br />

@keyframes animateMe-remove {<br />

to {font-size: 50px;}<br />

from {font-size: 16px;}<br />

}<br />

@-webkit-keyframes animateMe-remove {<br />

to {font-size: 50px;}<br />

from {font-size: 16px;}<br />

}<br />

All we need to do to apply the animation is include the animation CSS style on our classes:<br />

.animateMe.grown-add {<br />

-webkit-animation: 2s animateMe-add;<br />

animation: 2s animateMe-add;<br />

}<br />

.animateMe.grown-remove {<br />

-webkit-animation: 2s animateMe-remove;<br />

animation: 2s animateMe-remove;<br />

}<br />

JavaScript Animation<br />

When animati<strong>ng</strong> with JavaScript, we need to define the addClass and removeClass properties on<br />

our animation description object.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!