##AngularJS ngIf fade animation
Created
July 27, 2015 06:01
-
-
Save anonymoussc/54b18d0b61bd5a607b33 to your computer and use it in GitHub Desktop.
AngularJS ngIf fade 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
<!DOCTYPE html> | |
<html ng-app="myApp"> | |
<head> | |
<title>AngularJS ngIf fade animation</title> | |
<link href="style.css" rel="stylesheet"/> | |
</head> | |
<body> | |
<div ng-controller="animationsCtrl"> | |
<div> | |
fadeAnimation value: {{fadeAnimation}} | |
</div> | |
<button ng-click="fadeAnimation = !fadeAnimation">Toggle fade</button> | |
<div ng-if="fadeAnimation" class="animationIf"> | |
This element appears when the fadeAnimation model is true | |
</div> | |
</div> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular-animate.min.js"></script> | |
<script src="script.js"></script> | |
</body> | |
</html> |
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
var app = angular.module('myApp', ['ngAnimate']); | |
app.controller('animationsCtrl', function ($scope) { | |
$scope.fadeAnimation = false; | |
}); |
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
/* ngIf animation */ | |
.animationIf.ng-enter, | |
.animationIf.ng-leave { | |
-webkit-transition : opacity ease-in-out 1s; | |
-moz-transition : opacity ease-in-out 1s; | |
-ms-transition : opacity ease-in-out 1s; | |
-o-transition : opacity ease-in-out 1s; | |
transition : opacity ease-in-out 1s; | |
} | |
.animationIf.ng-enter, | |
.animationIf.ng-leave.ng-leave-active { | |
opacity : 0; | |
} | |
.animationIf.ng-leave, | |
.animationIf.ng-enter.ng-enter-active { | |
opacity : 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment