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>
复制代码

 


本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/7241515.html,如需转载请自行联系原作者

相关文章
|
5月前
|
JavaScript 前端开发
AngularJS ng-if使用方法详解
AngularJS ng-if使用方法详解
|
5月前
|
JavaScript
AngularJS ng-if使用
AngularJS ng-if使用
|
8月前
|
JavaScript 前端开发
AngularJS学习(一)
@[TOC](目录) ### 1. 引入 AngularJS 要使用 AngularJS,您需要首先引入 angular.js 文件。这可以通过在 HTML 文件中使用<script>标签来实现: ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script> ``` ### 2. 创建一个 AngularJS 应用 在 HTML 文件中,使用 ng-app 指令创建一个 AngularJS 应用。这个指令必须放在<html>标签内: ```ht
|
JavaScript 前端开发
|
Web App开发 JavaScript 前端开发
|
数据安全/隐私保护
AngularJS driective 封装 自动滚动插件
1.ui-smooth-scroll.js文件内容 angular.module('app') .directive('uiSmoothScroll', ['$location', '$anchorScroll', function($location, $anchorScroll)...
1122 0

热门文章

最新文章