]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * @private\r | |
3 | */\r | |
4 | Ext.define('Ext.fx.easing.Momentum', {\r | |
5 | \r | |
6 | extend: 'Ext.fx.easing.Abstract',\r | |
7 | \r | |
8 | config: {\r | |
9 | acceleration: 30,\r | |
10 | friction: 0,\r | |
11 | startVelocity: 0\r | |
12 | },\r | |
13 | \r | |
14 | alpha: 0,\r | |
15 | \r | |
16 | updateFriction: function(friction) {\r | |
17 | var theta = Math.log(1 - (friction / 10));\r | |
18 | \r | |
19 | this.theta = theta;\r | |
20 | \r | |
21 | this.alpha = theta / this.getAcceleration();\r | |
22 | },\r | |
23 | \r | |
24 | updateStartVelocity: function(velocity) {\r | |
25 | this.velocity = velocity * this.getAcceleration();\r | |
26 | },\r | |
27 | \r | |
28 | updateAcceleration: function(acceleration) {\r | |
29 | this.velocity = this.getStartVelocity() * acceleration;\r | |
30 | \r | |
31 | this.alpha = this.theta / acceleration;\r | |
32 | },\r | |
33 | \r | |
34 | getValue: function() {\r | |
35 | return this.getStartValue() - this.velocity * (1 - this.getFrictionFactor()) / this.theta;\r | |
36 | },\r | |
37 | \r | |
38 | getFrictionFactor: function() {\r | |
39 | var deltaTime = Ext.Date.now() - this.getStartTime();\r | |
40 | \r | |
41 | return Math.exp(deltaTime * this.alpha);\r | |
42 | },\r | |
43 | \r | |
44 | getVelocity: function() {\r | |
45 | return this.getFrictionFactor() * this.velocity;\r | |
46 | }\r | |
47 | });\r |