angular动画,angularjs动画demo,angularjs动画效果
web前端-js教程
废话不多说了,直接给大家贴实例代码。php的代码生成器源码,ubuntu删除不了文件,tomcat启用服务如何配置,京东 爬虫 稳定,yum安装php8,海南seo方法lzw
直接看例子:网页工具源码,vscode开发exe,ubuntu要安装在虚拟机吗,tomcat mem不降,sqlite 长整型字段,贴吧源系统优化插件,百度前端架构框架,八脚小爬虫,php 文件查找,龙海谷歌seo,物流网站免费模板,静态网页制作用什么软件,古典的网页模板免费下载lzw
引入angular-animate插件,我们绑定了ng-if指令,在删除和添加DOM节点的时候,angular会添加指定的class,方便我们完成动画。ngAnimate插件1 .box{width:200px;height:200px;background-color:red;transition:1s all;}/*显示操作*/.box.ng-enter{opacity:0;}.box.ng-enter-active{opacity:1;}/*隐藏操作*/.box.ng-leave{opacity:1;}.box.ng-leave-active{opacity:0;}var m1 = angular.module('myApp',['ngAnimate']);m1.controller('Aaa',['$scope',function($scope){$scope.bBtn = true;}]);
微信手机电影网站源码,vscode怎么烧录单片机,ubuntu减压命令,在sts里面tomcat,爬虫实验环境,php ecos框架,海尔和其他网站的seo分析,织梦网站 伪静态lzw
.ng-enter.ng-enter-active
.ng-leave
.ng-leave-active
现在再看看显示和隐藏。
.ng-hide-removengAnimate插件4 .box{width:200px;height:200px;background-color:red;transition:1s all;}/*显示操作*/.box.ng-hide-remove{opacity:0;}.box.ng-hide-remove-active{opacity:1;}/*隐藏操作*/.box.ng-hide-add{opacity:1;}.box.ng-hide-add-active{opacity:0;}var m1 = angular.module('myApp',['ngAnimate']);m1.controller('Aaa',['$scope',function($scope){$scope.bBtn = true;}]);
.ng-hide-remove-active
.ng-hide-add
.ng-hide-add-active
这个例子我们使用的是ng-show,属于显示和隐藏。上一个例子是ng-if,属于添加和删除。
回顾上一节我们提到的路由,我们可以结合起来操作。
这样在切换页面的时候就有淡入淡出的效果。ngAnimate插件2 .box{transition:1s all;position:absolute;}/*显示操作*/.box.ng-enter{opacity:0;}.box.ng-enter-active{opacity:1;}/*隐藏操作*/.box.ng-leave{opacity:1;}.box.ng-leave-active{opacity:0;}首页内容标题var m1 = angular.module('myApp',['ngRoute','ngAnimate']);m1.config(['$routeProvider',function($routeProvider){$routeProvider.when('/aaa',{template : 'AAA
{{name}}',controller : 'Aaa'}).when('/bbb',{template : 'BBB
{{name}}',controller : 'Bbb'}).when('/ccc',{template : 'CCC
{{name}}',controller : 'Ccc'}).otherwise({redirectTo : '/aaa'});}]);m1.controller('Aaa',['$scope','$location','$routeParams',function($scope,$location,$routeParams){$scope.name = 'xiecg-Aaa';$scope.$location = $location;}]);m1.controller('Bbb',['$scope',function($scope){$scope.name = 'xiecg-Bbb';}]);m1.controller('Ccc',['$scope',function($scope){$scope.name = 'xiecg-Ccc';}]);
再回顾前面的几章讲的百度搜索:
通过跨域我们得到百度返回过来的数据,依次过渡显示到页面上。ngAnimate插件3 .box{transition:1s all;}/*显示操作*/.box.ng-enter{opacity:0;}.box.ng-enter-active{opacity:1;}/*隐藏操作*/.box.ng-leave{display:none;}.box.ng-enter-stagger{animation-delay:0.1s;}{{d}}var m1 = angular.module('myApp',['ngAnimate']);m1.controller('Aaa',['$scope','$http','$timeout',function($scope,$http,$timeout){var timer = null;$scope.data = [];$scope.change = function(name){$timeout.cancel(timer);timer = $timeout(function(){$http({method : 'JSONP',url : 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+name+'&cb=JSON_CALLBACK',}).success(function(data,state,headers,config){console.log(data);$scope.data = data.s;}).error(function(data){console.log(data);});},500);};}]);
下面来看JS动画的例子:
JS动画我们使用JQ的动画库来完成,注意我们在视图上使用的是ng-if,表示添加和删除DOM节点,所以我们在控制器return leave&enter。ngAnimate插件5 .box{width:200px;height:200px;background-color:red;}var m1 = angular.module('myApp',['ngAnimate']);//ng-ifm1.animation('.box',function(){return {//hide(删除)leave : function(element,done){//console.log(element,done); //元素节点&删除节点的回调函数$(element).animate({width : 0,height : 0},1000,done);},//show(填充)enter : function(element,done){//ng-if会动态创建元素,元素默认就有200的高宽。。。$(element).css({width : 0,height : 0}).animate({width : 200,height : 200},1000,done);}};});m1.controller('Aaa',['$scope',function($scope){$scope.bBtn = true;}]);
JS动画有了ng-if,自然就是ng-show。
在控制器return addClass&removeClass,表示隐藏和显示。ngAnimate插件5 .box{width:200px;height:200px;background-color:red;}var m1 = angular.module('myApp',['ngAnimate']);//ng-showm1.animation('.box',function(){return {//hide(隐藏)addClass : function(element,sClass,done){//console.log(element,sClass,done); //元素节点&样式名&删除节点的回调函数$(element).animate({width : 0,height : 0},1000,done);},//show(显示)removeClass : function(element,sClass,done){$(element).animate({width : 200,height : 200},1000,done); }};});m1.controller('Aaa',['$scope',function($scope){$scope.bBtn = true;}]);
AngularJS中实现显示或隐藏动画效果的方式总结_AngularJS | AngularJS中实现显示或隐藏动画效果的方式总结_AngularJS ...