Skip to content

Commit

Permalink
Merge pull request ionic-team#1504 from driftyco/wip-ios7-animation-1
Browse files Browse the repository at this point in the history
feat(nav): Better iOS 7 navigation and nav bar animations
  • Loading branch information
mlynch committed May 27, 2014
2 parents 5f4c0a3 + 1c3dcc1 commit 2e8fd58
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 8 deletions.
26 changes: 19 additions & 7 deletions scss/_animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ $slide-in-up-function: cubic-bezier(.1, .7, .1, 1);
* iOS7 style slide left to right
* --------------------------------------------------
*/
$ios7-timing-function: ease-in-out;
$ios7-transition-duration: 250ms;
$ios7-timing-function: cubic-bezier(0.4, 0.6, 0.2, 1);
$ios7-transition-duration: 340ms;

.slide-left-right-ios7,
.slide-right-left-ios7.reverse {
Expand All @@ -354,6 +354,10 @@ $ios7-transition-duration: 250ms;
> .ng-enter, &.ng-enter {
/* NEW content placed far RIGHT BEFORE it slides IN from the RIGHT */
@include translate3d(100%, 0, 0);
z-index: 2;
}
> .ng-leave, &.ng-leave {
z-index: 1;
}
> .ng-enter.ng-enter-active, &.ng-enter.ng-enter-active {
/* NEW content ACTIVELY sliding IN from the RIGHT */
Expand All @@ -379,15 +383,19 @@ $ios7-transition-duration: 250ms;
}
> .ng-enter, &.ng-enter {
/* NEW content placed far LEFT BEFORE it slides IN from the LEFT */
@include translate3d(-100%, 0, 0);
@include translate3d(-15%, 0, 0);
z-index: 1;
}
> .ng-leave, &.ng-leave {
z-index: 2;
}
> .ng-enter.ng-enter-active, &.ng-enter.ng-enter-active {
/* NEW content ACTIVELY sliding IN from the LEFT */
@include translate3d(0, 0, 0);
}
> .ng-leave.ng-leave-active, &.ng-leave.ng-leave-active {
/* OLD content ACTIVELY sliding OUT to the RIGHT */
@include translate3d(15%, 0, 0);
@include translate3d(100%, 0, 0);
}
}

Expand Down Expand Up @@ -547,7 +555,7 @@ $ios7-transition-duration: 250ms;
/**
* Some component specific animations
*/
$nav-title-slide-ios7-delay: 250ms;
$nav-title-slide-ios7-delay: $ios7-transition-duration;
.nav-title-slide-ios7 {
&:not(.no-animation) .button.back-button {
@include transition(all $nav-title-slide-ios7-delay);
Expand Down Expand Up @@ -579,6 +587,9 @@ $nav-title-slide-ios7-delay: 250ms;
> .ng-enter, &.ng-enter {
@include translate3d(30%, 0, 0);
opacity: 0;
&.title {
@include translate3d(100%, 0, 0);
}
}
> .ng-enter.ng-enter-active, &.ng-enter.ng-enter-active {
@include translate3d(0, 0, 0);
Expand All @@ -592,7 +603,8 @@ $nav-title-slide-ios7-delay: 250ms;
&.reverse {
> .ng-enter, &.ng-enter,
> .ng-leave, &.ng-leave {
@include transition(all ease-in-out $transition-duration);
@include transition(all $nav-title-slide-ios7-delay);
@include transition-timing-function($ios7-timing-function);
opacity: 1;
}
> .ng-enter, &.ng-enter {
Expand All @@ -604,7 +616,7 @@ $nav-title-slide-ios7-delay: 250ms;
opacity: 1;
}
> .ng-leave.ng-leave-active, &.ng-leave.ng-leave-active {
@include translate3d(30%, 0, 0);
@include translate3d(100%, 0, 0);
opacity: 0;
}
}
Expand Down
159 changes: 159 additions & 0 deletions test/html/platforms.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<html ng-app="navState">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

<title>Platforms</title>

<link rel="stylesheet" href="../../../../dist/css/ionic.css">
<script src="../../../../dist/js/ionic.bundle.js"></script>
</head>
<body>

<div ng-controller="AppCtrl">
<ion-nav-bar class="nav-title-slide-ios7 bar-positive">
<ion-nav-back-button class="button-icon icon ion-ios7-arrow-back">
Back
</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view animation="slide-left-right-ios7"></ion-nav-view>
</div>

<script id="home.html" type="text/ng-template">
<ion-view title="Home">
<!--
<ion-nav-buttons side="left">
<button
class="button button-icon icon ion-navicon"
menu-toggle="left">
</button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button
class="button button-icon icon ion-close-circled"
ng-click="requestClearNotifications()">
</button>
<button
class="button button-icon icon ion-alert-circled"
ng-show="$root.showButton">
</button>
</ion-nav-buttons>
-->

<ion-content>
<a href="#/friends" class="button button-block button-primary">Friends</a>
<div class="list">

<label class="item item-input item-select">
<div class="input-label">
Lightsaber
</div>
<select>
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
</select>
</label>

</div>
</ion-content>
</ion-view>
</script>

<script id="friends.html" type="text/ng-template">
<ion-view title="Friends">
<!--
<ion-nav-buttons side="left">
<button
class="button button-icon icon ion-navicon"
menu-toggle="left">
</button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button
class="button button-icon icon ion-close-circled"
ng-click="requestClearNotifications()">
</button>
<button
class="button button-icon icon ion-alert-circled"
ng-show="$root.showButton">
</button>
</ion-nav-buttons>
-->

<ion-content>
<div class="list">

<label class="item item-input item-select">
<div class="input-label">
Lightsaber
</div>
<select>
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
</select>
</label>

</div>
</ion-content>
</ion-view>
</script>

<script id="about.html" type="text/ng-template">
<ion-view title="Home">
<!--
<ion-nav-buttons side="left">
<button
class="button button-icon icon ion-navicon"
menu-toggle="left">
</button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button
class="button button-icon icon ion-close-circled"
ng-click="requestClearNotifications()">
</button>
<button
class="button button-icon icon ion-alert-circled"
ng-show="$root.showButton">
</button>
</ion-nav-buttons>
-->

<ion-content>
<h1>About</h1>
</ion-content>
</ion-view>
</script>

<script>
angular.module('navState', ['ionic'])


.config(function($stateProvider, $urlRouterProvider) {

$stateProvider
.state('home', {
url: "/",
templateUrl: "home.html"
})
.state('friends', {
url: "/friends",
templateUrl: "friends.html"
})
.state('about', {
url: "/about",
templateUrl: "about.html"
})

$urlRouterProvider.otherwise("/");

})

.controller('AppCtrl', function($scope) {

});
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion test/html/viewState.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Back
</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view animation="slide-left-right"></ion-nav-view>
<ion-nav-view animation="slide-left-right-ios7"></ion-nav-view>
</div>

<script id="sign-in.html" type="text/ng-template">
Expand Down

0 comments on commit 2e8fd58

Please sign in to comment.