Modal animations.

This commit is contained in:
Max Lynch
2013-10-04 20:55:06 -05:00
parent c338f75882
commit 1f2619f6f8
8 changed files with 153 additions and 33 deletions

View File

@ -21,7 +21,9 @@ angular.module('ionic.service.modal', ['ionic.service'])
var element = $compile(templateString)(scope); var element = $compile(templateString)(scope);
$document[0].body.appendChild(element[0]); $document[0].body.appendChild(element[0]);
return new ionic.views.Modal({el: element[0] }); var modal = ionic.views.Modal({el: element[0] });
scope.modal = modal;
return modal;
}, },
fromTemplateUrl: function(url, cb) { fromTemplateUrl: function(url, cb) {
TemplateLoader.load(url).then(function(templateString) { TemplateLoader.load(url).then(function(templateString) {
@ -33,6 +35,7 @@ angular.module('ionic.service.modal', ['ionic.service'])
$document[0].body.appendChild(element[0]); $document[0].body.appendChild(element[0]);
var modal = new ionic.views.Modal({ el: element[0] }); var modal = new ionic.views.Modal({ el: element[0] });
scope.modal = modal;
cb(modal); cb(modal);
}); });

60
dist/ionic-ios7.css vendored
View File

@ -1,4 +1,3 @@
@charset "UTF-8";
/** /**
* Adapted from normalize.css and some reset.css. We don't care even one * Adapted from normalize.css and some reset.css. We don't care even one
* bit about old IE, so we don't need any hacks for that in here. * bit about old IE, so we don't need any hacks for that in here.
@ -182,7 +181,7 @@ sub {
fieldset { fieldset {
margin: 0 2px; margin: 0 2px;
padding: 0.35em 0.625em 0.75em; padding: 0.35em 0.625em 0.75em;
border: 1px solid silver; } border: 1px solid #c0c0c0; }
/** /**
* 1. Correct `color` not being inherited in IE 8/9. * 1. Correct `color` not being inherited in IE 8/9.
@ -1502,12 +1501,16 @@ address {
background-color: white; background-color: white;
opacity: 0; opacity: 0;
-webkit-transform: translate3d(0, 100%, 0); -webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0); } transform: translate3d(0, 100%, 0);
-webkit-transition: -webkit-transform 0.25s, opacity 0.25s;
transition: -webkit-transform 0.25s, opacity 0.25s;
-webkit-transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1);
transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1); }
.modal.active { .modal.active {
-webkit-transform: translate3d(0, 0%, 0);
transform: translate3d(0, 0%, 0);
opacity: 1; opacity: 1;
height: 100%; } height: 100%;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0); }
.list { .list {
margin-bottom: 20px; margin-bottom: 20px;
@ -1774,7 +1777,7 @@ select:focus,
input[type="file"]:focus, input[type="file"]:focus,
input[type="radio"]:focus, input[type="radio"]:focus,
input[type="checkbox"]:focus { input[type="checkbox"]:focus {
outline: thin dotted #333333; outline: thin dotted #333;
outline: 5px auto -webkit-focus-ring-color; outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px; } outline-offset: -2px; }
@ -1861,7 +1864,7 @@ input[type="checkbox"][readonly] {
right: 20px; right: 20px;
transition: 0.2s ease; transition: 0.2s ease;
transition-property: left, right; transition-property: left, right;
transition-delay: 0s, 0.05s; } transition-delay: 0s, .05s; }
.toggle :checked + .track { .toggle :checked + .track {
/* When the toggle is "on" */ /* When the toggle is "on" */
@ -1876,7 +1879,7 @@ input[type="checkbox"][readonly] {
right: 0; right: 0;
left: 20px; left: 20px;
-webkit-transform: none; -webkit-transform: none;
transition-delay: 0.05s, 0s; } transition-delay: .05s, 0s; }
/* hide a radio button's icon by default */ /* hide a radio button's icon by default */
.radio-item [class^="icon-"], .radio-item [class^="icon-"],
@ -2053,7 +2056,7 @@ input[type="checkbox"][readonly] {
border: none; border: none;
background: none; } background: none; }
.button.button-icon:active, .button.button-icon.active { .button.button-icon:active, .button.button-icon.active {
text-shadow: 0px 0px 10px white; text-shadow: 0px 0px 10px #fff;
box-shadow: none; box-shadow: none;
background: none; } background: none; }
@ -2236,7 +2239,7 @@ a.button {
width: 100%; width: 100%;
background-color: white; background-color: white;
border-radius: 2px; border-radius: 2px;
border: 1px solid #dddddd; } border: 1px solid #ddd; }
.card-header { .card-header {
padding: 10px; padding: 10px;
@ -2277,15 +2280,48 @@ a.button {
-webkit-transform: translate3d(0, 100%, 0); -webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0); } transform: translate3d(0, 100%, 0); }
5% {
opacity: 1; }
100% { 100% {
opacity: 1; opacity: 1;
-webkit-transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0); } } transform: translate3d(0, 0, 0); } }
@-webkit-keyframes slide-in-down {
0% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0); }
95% {
opacity: 0; }
100% {
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0); } }
.slide-in-up {
/*
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
animation: slide-in-down 0.5s;
-webkit-animation: slide-in-down 0.5s;
-webkit-animation-timing-function: $bezier-function;
*/ }
/*
-webkit-animation: slide-in-up 0.5s;
-webkit-animation-direction: reverse;
}
*/
.slide-in-up.active { .slide-in-up.active {
/*
animation: slide-in-up 0.5s; animation: slide-in-up 0.5s;
-webkit-animation: slide-in-up 0.5s; -webkit-animation: slide-in-up 0.5s;
-webkit-animation-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1); } -webkit-animation-fill-mode: forwards;
*/ }
@keyframes fadein { @keyframes fadein {
from { from {

56
dist/ionic.css vendored
View File

@ -1,4 +1,3 @@
@charset "UTF-8";
@font-face { @font-face {
font-family: 'ionicon-test'; font-family: 'ionicon-test';
src: url("fonts/ionicon-test.eot"); src: url("fonts/ionicon-test.eot");
@ -247,7 +246,7 @@ sub {
fieldset { fieldset {
margin: 0 2px; margin: 0 2px;
padding: 0.35em 0.625em 0.75em; padding: 0.35em 0.625em 0.75em;
border: 1px solid silver; } border: 1px solid #c0c0c0; }
/** /**
* 1. Correct `color` not being inherited in IE 8/9. * 1. Correct `color` not being inherited in IE 8/9.
@ -1560,12 +1559,16 @@ address {
background-color: white; background-color: white;
opacity: 0; opacity: 0;
-webkit-transform: translate3d(0, 100%, 0); -webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0); } transform: translate3d(0, 100%, 0);
-webkit-transition: -webkit-transform 0.25s, opacity 0.25s;
transition: -webkit-transform 0.25s, opacity 0.25s;
-webkit-transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1);
transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1); }
.modal.active { .modal.active {
-webkit-transform: translate3d(0, 0%, 0);
transform: translate3d(0, 0%, 0);
opacity: 1; opacity: 1;
height: 100%; } height: 100%;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0); }
.list { .list {
margin-bottom: 20px; margin-bottom: 20px;
@ -1832,7 +1835,7 @@ select:focus,
input[type="file"]:focus, input[type="file"]:focus,
input[type="radio"]:focus, input[type="radio"]:focus,
input[type="checkbox"]:focus { input[type="checkbox"]:focus {
outline: thin dotted #333333; outline: thin dotted #333;
outline: 5px auto -webkit-focus-ring-color; outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px; } outline-offset: -2px; }
@ -2105,7 +2108,7 @@ input[type="checkbox"][readonly] {
border: none; border: none;
background: none; } background: none; }
.button.button-icon:active, .button.button-icon.active { .button.button-icon:active, .button.button-icon.active {
text-shadow: 0px 0px 10px white; text-shadow: 0px 0px 10px #fff;
box-shadow: none; box-shadow: none;
background: none; } background: none; }
@ -2288,7 +2291,7 @@ a.button {
width: 100%; width: 100%;
background-color: white; background-color: white;
border-radius: 2px; border-radius: 2px;
border: 1px solid #dddddd; } border: 1px solid #ddd; }
.card-header { .card-header {
padding: 10px; padding: 10px;
@ -2329,15 +2332,48 @@ a.button {
-webkit-transform: translate3d(0, 100%, 0); -webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0); } transform: translate3d(0, 100%, 0); }
5% {
opacity: 1; }
100% { 100% {
opacity: 1; opacity: 1;
-webkit-transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0); } } transform: translate3d(0, 0, 0); } }
@-webkit-keyframes slide-in-down {
0% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0); }
95% {
opacity: 0; }
100% {
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0); } }
.slide-in-up {
/*
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
animation: slide-in-down 0.5s;
-webkit-animation: slide-in-down 0.5s;
-webkit-animation-timing-function: $bezier-function;
*/ }
/*
-webkit-animation: slide-in-up 0.5s;
-webkit-animation-direction: reverse;
}
*/
.slide-in-up.active { .slide-in-up.active {
/*
animation: slide-in-up 0.5s; animation: slide-in-up 0.5s;
-webkit-animation: slide-in-up 0.5s; -webkit-animation: slide-in-up 0.5s;
-webkit-animation-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1); } -webkit-animation-fill-mode: forwards;
*/ }
@keyframes fadein { @keyframes fadein {
from { from {

View File

@ -81,7 +81,7 @@
<div id="login-view" class="modal slide-in-up" ng-controller="LoginCtrl"> <div id="login-view" class="modal slide-in-up" ng-controller="LoginCtrl">
<header class="bar bar-header bar-success"> <header class="bar bar-header bar-success">
<h1 class="title">Log in</h1> <h1 class="title">Log in</h1>
<button class="button">Close</a> <button class="button" ng-click="close()">Close</button>
</header> </header>
<main class="content padded has-header"> <main class="content padded has-header">
<form class="form-horizontal" ng-submit="tryLogin(loginForm)"> <form class="form-horizontal" ng-submit="tryLogin(loginForm)">
@ -104,7 +104,6 @@
<div id="login-error" ng-show="loginError">Invalid email/password. Please try again.</div> <div id="login-error" ng-show="loginError">Invalid email/password. Please try again.</div>
</div> </div>
</form> </form>
<button ng-click="showSignup()" id="signup-button" class="button button-default button-block">Create an account</button>
</main> </main>
</div> </div>
</script> </script>

View File

@ -29,8 +29,8 @@ angular.module('ionic.todo.controllers', ['ionic.todo', 'ionic.service.modal', '
password: 'test' password: 'test'
}; };
$scope.showSignup = function() { $scope.close = function() {
$scope.navController.pushFromTemplate('signup.html'); $scope.modal.hide();
}; };
$scope.tryLogin = function(data) { $scope.tryLogin = function(data) {
@ -57,6 +57,7 @@ angular.module('ionic.todo.controllers', ['ionic.todo', 'ionic.service.modal', '
}; };
$scope.showLogin = function() { $scope.showLogin = function() {
$scope.loginModal && $scope.loginModal.show();
}; };
}) })

View File

@ -17,7 +17,9 @@ angular.module('ionic.service.modal', ['ionic.service'])
var element = $compile(templateString)(scope); var element = $compile(templateString)(scope);
$document[0].body.appendChild(element[0]); $document[0].body.appendChild(element[0]);
return new ionic.views.Modal({el: element[0] }); var modal = ionic.views.Modal({el: element[0] });
scope.modal = modal;
return modal;
}, },
fromTemplateUrl: function(url, cb) { fromTemplateUrl: function(url, cb) {
TemplateLoader.load(url).then(function(templateString) { TemplateLoader.load(url).then(function(templateString) {
@ -29,6 +31,7 @@ angular.module('ionic.service.modal', ['ionic.service'])
$document[0].body.appendChild(element[0]); $document[0].body.appendChild(element[0]);
var modal = new ionic.views.Modal({ el: element[0] }); var modal = new ionic.views.Modal({ el: element[0] });
scope.modal = modal;
cb(modal); cb(modal);
}); });

View File

@ -15,6 +15,9 @@ $bezier-function: cubic-bezier(.1, .7, .1, 1);
-webkit-transform: translate3d(0, 100%, 0); -webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0); transform: translate3d(0, 100%, 0);
} }
5% {
opacity: 1;
}
100% { 100% {
opacity: 1; opacity: 1;
-webkit-transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0);
@ -22,10 +25,45 @@ $bezier-function: cubic-bezier(.1, .7, .1, 1);
} }
} }
@-webkit-keyframes slide-in-down {
0% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
95% {
opacity: 0;
}
100% {
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
}
.slide-in-up {
/*
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
animation: slide-in-down 0.5s;
-webkit-animation: slide-in-down 0.5s;
-webkit-animation-timing-function: $bezier-function;
*/
}
/*
-webkit-animation: slide-in-up 0.5s;
-webkit-animation-direction: reverse;
}
*/
.slide-in-up.active { .slide-in-up.active {
/*
animation: slide-in-up 0.5s; animation: slide-in-up 0.5s;
-webkit-animation: slide-in-up 0.5s; -webkit-animation: slide-in-up 0.5s;
-webkit-animation-timing-function: $bezier-function; -webkit-animation-fill-mode: forwards;
*/
} }
@keyframes fadein { @keyframes fadein {

View File

@ -22,13 +22,17 @@
// Start it down low // Start it down low
-webkit-transform: translate3d(0, 100%, 0); -webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0); transform: translate3d(0, 100%, 0);
-webkit-transition: -webkit-transform 0.25s, opacity 0.25s;
transition: -webkit-transform 0.25s, opacity 0.25s;
-webkit-transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1);
transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1);
// Active modal // Active modal
&.active { &.active {
-webkit-transform: translate3d(0, 0%, 0);
transform: translate3d(0, 0%, 0);
opacity: 1; opacity: 1;
height: 100%; height: 100%;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
} }
} }