diff --git a/app/app.animations.css b/app/app.animations.css new file mode 100644 index 000000000..175320b50 --- /dev/null +++ b/app/app.animations.css @@ -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! */ diff --git a/app/app.animations.js b/app/app.animations.js new file mode 100644 index 000000000..394fcc944 --- /dev/null +++ b/app/app.animations.js @@ -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(); + }; + } + }); diff --git a/app/app.css b/app/app.css index eb74556db..f4b45b02a 100644 --- a/app/app.css +++ b/app/app.css @@ -4,6 +4,7 @@ body { h1 { border-bottom: 1px solid gray; + margin-top: 0; } /* View: Phone list */ @@ -28,7 +29,7 @@ h1 { /* View: Phone detail */ .phone { background-color: white; - border: 1px solid black; + display: none; float: left; height: 400px; margin-bottom: 2em; @@ -37,6 +38,19 @@ h1 { width: 400px; } +.phone:first-child { + display: block; +} + +.phone-images { + background-color: white; + float: left; + height: 450px; + overflow: hidden; + position: relative; + width: 450px; +} + .phone-thumbs { list-style: none; margin: 0; diff --git a/app/app.module.js b/app/app.module.js index 651b0a20b..8c392c4d6 100644 --- a/app/app.module.js +++ b/app/app.module.js @@ -2,6 +2,7 @@ // Define the `phonecatApp` module angular.module('phonecatApp', [ + 'ngAnimate', 'ngRoute', 'core', 'phoneDetail', diff --git a/app/index.html b/app/index.html index abab94cf6..dd1e0891d 100644 --- a/app/index.html +++ b/app/index.html @@ -5,11 +5,16 @@ Google Phone Gallery + + + + + @@ -21,7 +26,9 @@ -
+
+
+
diff --git a/app/phone-detail/phone-detail.template.html b/app/phone-detail/phone-detail.template.html index 09061ce7a..f48657803 100644 --- a/app/phone-detail/phone-detail.template.html +++ b/app/phone-detail/phone-detail.template.html @@ -1,4 +1,8 @@ - +
+ +

{{$ctrl.phone.name}}

diff --git a/app/phone-list/phone-list.template.html b/app/phone-list/phone-list.template.html index b0d81d4cb..90548f9f9 100644 --- a/app/phone-list/phone-list.template.html +++ b/app/phone-list/phone-list.template.html @@ -21,7 +21,8 @@