angularjs1--动画

Posted 672530440

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了angularjs1--动画相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style>
        .box{ width:200px; height:200px; background:red; }
    </style>
    <script src="jquery-1.11.1.js"></script>
    <script src="angular.min.js"></script>
    <script src="http://cdn.bootcss.com/angular.js/1.2.9/angular-animate.min.js"></script>
    <script>
        var m1 = angular.module(myApp,[ngAnimate]);
        m1.controller(firstController,[$scope,function($scope){
            $scope.bBtn = true;
        }]);
        m1.animation(.box,function(){
            return{
                enter:function(element,done){
                    console.log(element);
                    console.log(done);
                    $(element).css({width:0,height:0});
                    ///   $(element).animate({width:0,height:0});
                    $(element).animate({width:200,height:200},1000,done);
                },
                leave:function(element,done){
                    $(element).animate({width:0,height:0},1000,done);
                }
            }
        });
    </script>
</head>
<body>
<div ng-controller="firstController">
    <input type="checkbox" ng-model="bBtn">
    <div ng-if="bBtn" class="box"></div>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style>
        .box{ width:200px; height:200px; background:red; }
    </style>
    <script src="jquery-1.11.1.js"></script>
    <script src="angular.min.js"></script>
    <script src="http://cdn.bootcss.com/angular.js/1.2.9/angular-animate.min.js"></script>
    <script>
        var m1 = angular.module(myApp,[ngAnimate]);
        m1.controller(firstController,[$scope,function($scope){
            $scope.bBtn = true;
        }]);
        m1.animation(.box,function(){
            return{
                addClass:function(element,Sclass,done){
//                    console.log(element);
//                    console.log(Sclass);
//                    console.log(done);
                    $(element).animate({width:0,height:0},1000,done);
                },
                removeClass:function(element,Sclass,done){
                    $(element).css({width:0,height:0});
                    $(element).animate({width:200,height:200},1000,done);
                }
            }
        });
    </script>
</head>
<body>
<div ng-controller="firstController">
    <input type="checkbox" ng-model="bBtn">
    <div ng-show="bBtn" class="box"></div>
</div>
</body>
</html>

 

以上是关于angularjs1--动画的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS动画

VSCode自定义代码片段7——CSS动画

VSCode自定义代码片段7——CSS动画

AngularJS 1.2从0到0.5的淡入淡出动画不起作用

使用嵌套片段和动画对象

Android:将“ViewPager”动画从片段更改为片段