|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -angular.module('ngShowcaseApp').controller('ctrl.animation.custom', function ($scope,$http,$timeout) { |
4 | | - var vm = $scope.vm = {}; |
5 | | - $scope.choice = ""; |
6 | | - $scope.classname = ""; |
7 | | - $scope.choiceitems = {}; |
8 | | - $http({method: 'GET', url: 'scripts/controllers/animation/choiceitems.json',cache:true}). |
| 3 | +angular.module('ngShowcaseApp').value('animate_param', { |
| 4 | + opacity: "1", |
| 5 | + left: "0", |
| 6 | + top: "0", |
| 7 | + time: "1000" |
| 8 | +}); |
| 9 | + |
| 10 | +angular.module('ngShowcaseApp').controller('ctrl.animation.custom', function($scope, $http, $timeout, animate_param) { |
| 11 | + var vm = $scope.vm = {}; |
| 12 | + $scope.choice = ""; |
| 13 | + $scope.classname = ""; |
| 14 | + $scope.choiceitems = {}; |
| 15 | + var vm = $scope.vm = {}; |
| 16 | + vm.items = ['item1', 'item2']; |
| 17 | + vm.itemId = 3; |
| 18 | + // user.opacity = $scope.param_opacity; |
| 19 | + |
| 20 | + vm.addItem = function() { |
| 21 | + vm.items.push('item' + vm.itemId); |
| 22 | + vm.itemId++; |
| 23 | + }; |
| 24 | + |
| 25 | + vm.delItem = function(index) { |
| 26 | + vm.items.splice(index, 1); |
| 27 | + }; |
| 28 | + $http({ |
| 29 | + method: 'GET', |
| 30 | + url: 'scripts/controllers/animation/choiceitems.json', |
| 31 | + cache: true |
| 32 | + }). |
9 | 33 | success(function(data, status, headers, config) { |
10 | | - var choices = angular.fromJson(data); |
11 | | - $scope.choiceitems = choices; |
| 34 | + var choices = angular.fromJson(data); |
| 35 | + $scope.choiceitems = choices; |
12 | 36 |
|
13 | 37 | }). |
14 | 38 | error(function(data, status, headers, config) { |
15 | | - console.log(data); |
| 39 | + console.log(data); |
16 | 40 | }); |
17 | | - $scope.change = function(){ |
18 | | - $scope.classname = $scope.choice+" "+"animated"; |
19 | | - var timer = $timeout(function() {$scope.classname = "";$timeout.cancel(timer);},1500); |
20 | | - }; |
| 41 | + $scope.change = function() { |
| 42 | + $scope.classname = $scope.choice + " " + "animated"; |
| 43 | + }; |
| 44 | + $scope.paramchange = function() { |
| 45 | + animate_param.opacity = $scope.param_opacity; |
| 46 | + animate_param.left = $scope.param_left; |
| 47 | + animate_param.top = $scope.param_top; |
| 48 | + animate_param.time = $scope.param_time; |
| 49 | + } |
| 50 | +}); |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +angular.module('ngShowcaseApp').animation('.list-group-item', |
| 56 | + function(animate_param) { |
| 57 | + return { |
| 58 | + enter: function(element, done) { |
| 59 | + console.log(animate_param); |
| 60 | + element.css('opacity', animate_param.opacity); |
| 61 | + element.css('left', animate_param.left + "px"); |
| 62 | + element.css('top', animate_param.top + "px"); |
| 63 | + jQuery(element).animate({ |
| 64 | + opacity: 1, |
| 65 | + left: '0px', |
| 66 | + top: '0px' |
| 67 | + }, (animate_param.time > 999) ? parseInt(animate_param.time) : 1000, done); |
| 68 | + return function(isCancelled) { |
| 69 | + if (isCancelled) { |
| 70 | + jQuery(element).stop(); |
| 71 | + } |
| 72 | + } |
| 73 | + }, |
| 74 | + leave: function(element, done) { |
| 75 | + element.css('opacity', 1); |
| 76 | + jQuery(element).animate({ |
| 77 | + opacity: 0 |
| 78 | + }, done); |
| 79 | + return function(isCancelled) { |
| 80 | + if (isCancelled) { |
| 81 | + jQuery(element).stop(); |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + }; |
| 86 | + |
| 87 | + } |
| 88 | +); |
| 89 | + |
| 90 | + |
| 91 | +/* |
| 92 | +myModule.animation('.repeated-item', function() { |
| 93 | + return { |
| 94 | + enter : function(element, done) { |
| 95 | + element.css('opacity',0); |
| 96 | + jQuery(element).animate({ |
| 97 | + opacity: 1 |
| 98 | + }, done); |
| 99 | +
|
| 100 | + // optional onDone or onCancel callback |
| 101 | + // function to handle any post-animation |
| 102 | + // cleanup operations |
| 103 | + return function(isCancelled) { |
| 104 | + if(isCancelled) { |
| 105 | + jQuery(element).stop(); |
| 106 | + } |
| 107 | + } |
| 108 | + }, |
| 109 | + leave : function(element, done) { |
| 110 | + element.css('opacity', 1); |
| 111 | + jQuery(element).animate({ |
| 112 | + opacity: 0 |
| 113 | + }, done); |
| 114 | +
|
| 115 | + // optional onDone or onCancel callback |
| 116 | + // function to handle any post-animation |
| 117 | + // cleanup operations |
| 118 | + return function(isCancelled) { |
| 119 | + if(isCancelled) { |
| 120 | + jQuery(element).stop(); |
| 121 | + } |
| 122 | + } |
| 123 | + }, |
| 124 | + move : function(element, done) { |
| 125 | + element.css('opacity', 0); |
| 126 | + jQuery(element).animate({ |
| 127 | + opacity: 1 |
| 128 | + }, done); |
| 129 | +
|
| 130 | + // optional onDone or onCancel callback |
| 131 | + // function to handle any post-animation |
| 132 | + // cleanup operations |
| 133 | + return function(isCancelled) { |
| 134 | + if(isCancelled) { |
| 135 | + jQuery(element).stop(); |
| 136 | + } |
| 137 | + } |
| 138 | + }, |
| 139 | +
|
| 140 | + // you can also capture these animation events |
| 141 | + addClass : function(element, className, done) {}, |
| 142 | + removeClass : function(element, className, done) {} |
| 143 | + } |
21 | 144 | }); |
| 145 | +*/ |
0 commit comments