This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add animations to the application: - Animate changes to the phone list, adding, removing and reordering phones with `ngRepeat`. - Animate view transitions with `ngView`. - Animate changes to the main phone image in the phone detail view. - Showcase three different kinds of animations: - CSS transition animations. - CSS keyframe animations. - JavaScript-based animations.
- Loading branch information
1 parent
ad5993c
commit f15c630
Showing
11 changed files
with
157 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* Animate `ngRepeat` in `phoneList` component */ | ||
.phone-list-item.ng-enter, | ||
.phone-list-item.ng-leave, | ||
.phone-list-item.ng-move { | ||
overflow: hidden; | ||
transition: 0.5s linear all; | ||
} | ||
|
||
.phone-list-item.ng-enter, | ||
.phone-list-item.ng-leave.ng-leave-active, | ||
.phone-list-item.ng-move { | ||
height: 0; | ||
margin-bottom: 0; | ||
opacity: 0; | ||
padding-bottom: 0; | ||
padding-top: 0; | ||
} | ||
|
||
.phone-list-item.ng-enter.ng-enter-active, | ||
.phone-list-item.ng-leave, | ||
.phone-list-item.ng-move.ng-move-active { | ||
height: 120px; | ||
margin-bottom: 20px; | ||
opacity: 1; | ||
padding-bottom: 4px; | ||
padding-top: 15px; | ||
} | ||
|
||
/* Animate view transitions with `ngView` */ | ||
.view-container { | ||
position: relative; | ||
} | ||
|
||
.view-frame { | ||
margin-top: 20px; | ||
} | ||
|
||
.view-frame.ng-enter, | ||
.view-frame.ng-leave { | ||
background: white; | ||
left: 0; | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
} | ||
|
||
.view-frame.ng-enter { | ||
animation: 1s fade-in; | ||
z-index: 100; | ||
} | ||
|
||
.view-frame.ng-leave { | ||
animation: 1s fade-out; | ||
z-index: 99; | ||
} | ||
|
||
@keyframes fade-in { | ||
from { opacity: 0; } | ||
to { opacity: 1; } | ||
} | ||
|
||
@keyframes fade-out { | ||
from { opacity: 1; } | ||
to { opacity: 0; } | ||
} | ||
|
||
/* Older browsers might need vendor-prefixes for keyframes and animation! */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
angular. | ||
module('phonecatApp'). | ||
animation('.phone', function phoneAnimationFactory() { | ||
return { | ||
addClass: animateIn, | ||
removeClass: animateOut | ||
}; | ||
|
||
function animateIn(element, className, done) { | ||
if (className !== 'selected') return; | ||
|
||
element.css({ | ||
display: 'block', | ||
position: 'absolute', | ||
top: 500, | ||
left: 0 | ||
}).animate({ | ||
top: 0 | ||
}, done); | ||
|
||
return function animateInEnd(wasCanceled) { | ||
if (wasCanceled) element.stop(); | ||
}; | ||
} | ||
|
||
function animateOut(element, className, done) { | ||
if (className !== 'selected') return; | ||
|
||
element.css({ | ||
position: 'absolute', | ||
top: 0, | ||
left: 0 | ||
}).animate({ | ||
top: -500 | ||
}, done); | ||
|
||
return function animateOutEnd(wasCanceled) { | ||
if (wasCanceled) element.stop(); | ||
}; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters