Skip to content

Commit 9c43dda

Browse files
mlynchajoslin
authored andcommitted
More timing functions
1 parent 0b47d80 commit 9c43dda

File tree

3 files changed

+56
-23
lines changed

3 files changed

+56
-23
lines changed

js/animation/animation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
tf = tf(this.duration);
102102

103103
return this._run(function(percent, now, virtual) {
104-
//console.log('Animation step', percent, now, virtual);
104+
console.log(percent);
105105
self.el[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + (percent * 400) + 'px, 0,0)';
106106
}, function() {
107107
return true;

js/animation/timing-functions.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,35 @@
55

66

77
ionic.Animation.TimingFn = {
8+
'linear': function(duration) {
9+
return function(t) {
10+
return t;
11+
}
12+
},
13+
'ease': function(duration) {
14+
var bz = ionic.Animation.Bezier.getCubicBezier(0.25, 0.1, 0.25, 1.0, duration);
15+
return function(t) {
16+
return bz(t);
17+
}
18+
},
19+
'ease-in': function(duration) {
20+
//0.42, 0.0, 1.0, 1.0
21+
var bz = ionic.Animation.Bezier.getCubicBezier(0.42, 0.0, 1.0, 1.0, duration);
22+
return function(t) {
23+
return bz(t);
24+
}
25+
},
26+
'ease-out': function(duration) {
27+
var bz = ionic.Animation.Bezier.getCubicBezier(0.0, 0.0, 0.58, 1.0, duration);
28+
return function(t) {
29+
return bz(t);
30+
}
31+
},
832
'ease-in-out': function(duration) {
933
var bz = ionic.Animation.Bezier.getCubicBezier(0.42, 0.0, 0.58, 1.0, duration);
1034
return function(t) {
11-
//console.log(t);
1235
return bz(t);
1336
}
14-
/*
15-
0.42, 0.0, 0.58, 1.0)
16-
17-
t /= d/2;
18-
if (t < 1) return c/2*t*t*t + b;
19-
t -= 2;
20-
return c/2*(t*t*t + 2) + b;
21-
*/
2237
}
2338
};
2439
})(window);

test/html/animation.html

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html ng-app="ionic">
2+
<html ng-app="myApp">
33
<head>
44
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
55
<title></title>
@@ -14,6 +14,11 @@
1414
height: 100px;
1515
background-color: black;
1616
}
17+
#opts {
18+
position: absolute;
19+
top: 200px;
20+
left: 10px;
21+
}
1722
</style>
1823

1924
</head>
@@ -22,23 +27,36 @@
2227

2328
<div ng-controller="MyCtrl">
2429
<div class="box"></div>
30+
<div id="opts">
31+
<button ng-click="do('{{v}}')" ng-repeat="v in fns">{{v}}</button>
32+
</div>
2533
</div>
2634

2735
<script>
28-
function MyCtrl($scope, $ionicAnimation) {
36+
angular.module('myApp', ['ionic'])
37+
.controller('MyCtrl', function($scope, $ionicAnimation) {
38+
$scope.fns = [
39+
'linear',
40+
'ease',
41+
'ease-in',
42+
'ease-out',
43+
'ease-in-out'
44+
];
2945
var el = angular.element(document.querySelector('.box'));
30-
var fadeIn = $ionicAnimation({
31-
el: el,
32-
name: 'fadeIn',
33-
duration: 500,
34-
delay: 0,
35-
autoReverse: false,
36-
repeat: -1,
37-
curve: 'ease-in-out'
38-
});
46+
$scope.do = function(fn) {
47+
var fadeIn = $ionicAnimation({
48+
el: el,
49+
name: 'fadeIn',
50+
duration: 500,
51+
delay: 0,
52+
autoReverse: false,
53+
repeat: -1,
54+
curve: fn
55+
});
3956

40-
fadeIn.start();
41-
}
57+
fadeIn.start();
58+
}
59+
});
4260
</script>
4361
</body>
4462
</html>

0 commit comments

Comments
 (0)