Skip to content

Commit 8aea777

Browse files
mlynchajoslin
authored andcommitted
Expanded test and callback system
1 parent 70370f1 commit 8aea777

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

js/animation/animation.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
delay: 0,
8181
repeat: -1,
8282

83+
step: function(percent) {},
84+
8385
stop: function() {
8486
},
8587

@@ -100,8 +102,10 @@
100102
// Get back a timing function for the given duration (used for precision)
101103
tf = tf(this.duration);
102104

103-
return this._run(function(percent, now, virtual) {
104-
self.el[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + (percent * 400) + 'px, 0,0)';
105+
return this._run(function(percent, now, render) {
106+
if(render) {
107+
self.step(percent);
108+
}
105109
}, function() {
106110
return true;
107111
}, function(droppedFrames, finishedAnimation) {

test/html/animation.html

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@
2828
<div ng-controller="MyCtrl">
2929
<div class="box"></div>
3030
<div id="opts">
31+
<label>
32+
Duration:
33+
<input type="number" ng-model="anim.duration">
34+
</label>
35+
<label>
36+
Repeat
37+
<input type="number" ng-model="anim.repeat">
38+
</label>
39+
<label>
40+
Delay
41+
<input type="number" ng-model="anim.delay">
42+
</label>
43+
<label>
44+
Auto reverse
45+
<input type="checkbox" ng-model="anim.autoReverse">
46+
</label>
3147
<button ng-click="do('{{v}}')" ng-repeat="v in fns">{{v}}</button>
3248
</div>
3349
</div>
@@ -42,17 +58,26 @@
4258
'ease-out',
4359
'ease-in-out'
4460
];
61+
$scope.anim = {
62+
duration: 500,
63+
delay: 0,
64+
repeat: -1,
65+
autoReverse: false
66+
}
4567
var el = angular.element(document.querySelector('.box'));
4668
$scope.do = function(fn) {
47-
var fadeIn = $ionicAnimation({
69+
var fadeIn = $ionicAnimation(angular.extend({
4870
el: el,
4971
name: 'fadeIn',
5072
duration: 500,
5173
delay: 0,
5274
autoReverse: false,
5375
repeat: -1,
54-
curve: fn
55-
});
76+
curve: fn,
77+
step: function(v) {
78+
el[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + (v * 400) + 'px, 0,0)';
79+
}
80+
}, $scope.anim));
5681

5782
fadeIn.start();
5883
}

0 commit comments

Comments
 (0)