@@ -56,72 +56,27 @@ suite('timing-utilities', function() {
56
56
assert . equal ( f ( 0.1 ) , 0.1 ) ;
57
57
assert . equal ( f ( 0.25 ) , 0.2 ) ;
58
58
} ) ;
59
- test ( 'calculating phase' , function ( ) {
60
- // calculatePhase(activeDuration, localTime, timing);
61
- assert . equal ( calculatePhase ( 1000 , 100 , { delay : 0 } ) , PhaseActive ) ;
62
- assert . equal ( calculatePhase ( 1000 , 100 , { delay : 200 } ) , PhaseBefore ) ;
63
- assert . equal ( calculatePhase ( 1000 , 2000 , { delay : 200 } ) , PhaseAfter ) ;
64
- assert . equal ( calculatePhase ( 1000 , null , { delay : 200 } ) , PhaseNone ) ;
65
- } ) ;
66
- test ( 'calculating active time' , function ( ) {
67
- // calculateActiveTime(activeDuration, fillMode, localTime, phase, delay);
68
- assert . equal ( calculateActiveTime ( 1000 , 'forwards' , 100 , PhaseActive , 0 ) , 100 ) ;
69
- assert . equal ( calculateActiveTime ( 1000 , 'forwards' , 100 , PhaseBefore , 200 ) , null ) ;
70
- assert . equal ( calculateActiveTime ( 1000 , 'both' , 100 , PhaseBefore , 200 ) , 0 ) ;
71
- assert . equal ( calculateActiveTime ( 1000 , 'forwards' , 500 , PhaseActive , 200 ) , 300 ) ;
72
- assert . equal ( calculateActiveTime ( 1000 , 'forwards' , 1100 , PhaseAfter , 200 ) , 1000 ) ;
73
- assert . equal ( calculateActiveTime ( 1000 , 'none' , 1100 , PhaseAfter , 200 ) , null ) ;
74
- assert . equal ( calculateActiveTime ( Infinity , 'both' , 5000000 , PhaseActive , 2000000 ) , 3000000 ) ;
75
- assert . equal ( calculateActiveTime ( Infinity , 'both' , 50000 , PhaseBefore , 2000000 ) , 0 ) ;
76
- } ) ;
77
- test ( 'calculating scaled active time' , function ( ) {
78
- // calculateScaledActiveTime(activeDuration, activeTime, startOffset, timingInput);
79
- assert . equal ( calculateScaledActiveTime ( 1000 , 200 , 300 , { playbackRate : 1.5 } ) , 600 ) ;
80
- assert . equal ( calculateScaledActiveTime ( 1000 , 200 , 300 , { playbackRate : - 4 } ) , 3500 ) ;
81
- assert . equal ( calculateScaledActiveTime ( Infinity , 400 , 200 , { playbackRate : 1 } ) , 600 ) ;
82
- assert . equal ( calculateScaledActiveTime ( Infinity , 400 , 200 , { playbackRate : - 4 } ) , Infinity ) ;
83
- } ) ;
84
- test ( 'calculating iteration time' , function ( ) {
85
- // calculateIterationTime(iterationDuration, repeatedDuration, scaledActiveTime, startOffset, timingInput);
86
- assert . equal ( calculateIterationTime ( 500 , 5000 , 600 , 100 , { iterations : 10 , iterationStart : 0 } ) , 100 ) ;
87
- assert . equal ( calculateIterationTime ( 500 , 5000 , Infinity , 100 , { iterations : 10 , iterationStart : 0 } ) , 500 ) ;
88
- assert . equal ( calculateIterationTime ( 500 , 5000 , 5100 , 100 , { iterations : 3.2 , iterationStart : 0.8 } ) , 500 ) ;
89
- } ) ;
90
- test ( 'calculating current iteration' , function ( ) {
91
- // calculateCurrentIteration(iterationDuration, iterationTime, scaledActiveTime, timingInput);
92
- assert . equal ( calculateCurrentIteration ( 1000 , 400 , 4400 , { iterations : 50 , iterationStart : 0.8 } ) , 4 ) ;
93
- assert . equal ( calculateCurrentIteration ( 1000 , 1000 , 4400 , { iterations : 50.2 , iterationStart : 0.8 } ) , 50 ) ;
94
- } ) ;
95
- test ( 'calculating transformed time' , function ( ) {
96
- // calculateTransformedTime(currentIteration, iterationDuration, iterationTime, timingInput);
97
- assert . equal ( calculateTransformedTime ( 4 , 1000 , 200 , { _easingFunction : function ( x ) { return x ; } , direction : 'normal' } ) , 200 ) ;
98
- assert . equal ( calculateTransformedTime ( 4 , 1000 , 200 , { _easingFunction : function ( x ) { return x ; } , direction : 'reverse' } ) , 800 ) ;
99
- assert . closeTo ( calculateTransformedTime ( 4 , 1000 , 200 , { _easingFunction : function ( x ) { return x * x ; } , direction : 'reverse' } ) , 640 , 0.0001 ) ;
100
- assert . closeTo ( calculateTransformedTime ( 4 , 1000 , 600 , { _easingFunction : function ( x ) { return x * x ; } , direction : 'alternate' } ) , 360 , 0.0001 ) ;
101
- assert . closeTo ( calculateTransformedTime ( 3 , 1000 , 600 , { _easingFunction : function ( x ) { return x * x ; } , direction : 'alternate' } ) , 160 , 0.0001 ) ;
102
- assert . closeTo ( calculateTransformedTime ( 4 , 1000 , 600 , { _easingFunction : function ( x ) { return x * x ; } , direction : 'alternate-reverse' } ) , 160 , 0.0001 ) ;
103
- assert . closeTo ( calculateTransformedTime ( 3 , 1000 , 600 , { _easingFunction : function ( x ) { return x * x ; } , direction : 'alternate-reverse' } ) , 360 , 0.0001 ) ;
104
- } ) ;
105
59
test ( 'EffectTime' , function ( ) {
106
60
var timing = normalizeTimingInput ( { duration : 1000 , iterations : 4 , iterationStart : 0.5 , easing : 'linear' , direction : 'alternate' , delay : 100 , fill : 'forwards' } ) ;
107
61
var timing2 = normalizeTimingInput ( { duration : 1000 , iterations : 4 , iterationStart : 0.5 , easing : 'ease' , direction : 'alternate' , delay : 100 , fill : 'forwards' } ) ;
108
62
var effectTF = effectTime ( timing ) ;
109
63
var effectTF2 = effectTime ( timing2 ) ;
64
+ var epsilon = 0.005 ;
110
65
assert . equal ( effectTF ( 0 ) , null ) ;
111
66
assert . equal ( effectTF ( 100 ) , 0.5 ) ;
112
- assert . closeTo ( effectTF2 ( 100 ) , 0.8 , 0.005 ) ;
67
+ assert . closeTo ( effectTF2 ( 100 ) , 0.8 , epsilon ) ;
113
68
assert . equal ( effectTF ( 600 ) , 1 ) ;
114
- assert . closeTo ( effectTF2 ( 600 ) , 1 , 0.005 ) ;
115
- assert . equal ( effectTF ( 700 ) , 0.9 ) ;
116
- assert . closeTo ( effectTF2 ( 700 ) , 0.99 , 0.005 ) ;
69
+ assert . closeTo ( effectTF2 ( 600 ) , 1 , epsilon ) ;
70
+ assert . closeTo ( effectTF ( 700 ) , 0.9 , epsilon ) ;
71
+ assert . closeTo ( effectTF2 ( 700 ) , 0.99 , epsilon ) ;
117
72
assert . equal ( effectTF ( 1600 ) , 0 ) ;
118
- assert . closeTo ( effectTF2 ( 1600 ) , 0 , 0.005 ) ;
119
- assert . equal ( effectTF ( 4000 ) , 0.4 ) ;
120
- assert . closeTo ( effectTF2 ( 4000 ) , 0.68 , 0.005 ) ;
73
+ assert . closeTo ( effectTF2 ( 1600 ) , 0 , epsilon ) ;
74
+ assert . closeTo ( effectTF ( 4000 ) , 0.4 , epsilon ) ;
75
+ assert . closeTo ( effectTF2 ( 4000 ) , 0.68 , epsilon ) ;
121
76
assert . equal ( effectTF ( 4100 ) , 0.5 ) ;
122
- assert . closeTo ( effectTF2 ( 4100 ) , 0.8 , 0.005 ) ;
77
+ assert . closeTo ( effectTF2 ( 4100 ) , 0.8 , epsilon ) ;
123
78
assert . equal ( effectTF ( 6000 ) , 0.5 ) ;
124
- assert . closeTo ( effectTF2 ( 6000 ) , 0.8 , 0.005 ) ;
79
+ assert . closeTo ( effectTF2 ( 6000 ) , 0.8 , epsilon ) ;
125
80
} ) ;
126
81
test ( 'TypeErrors' , function ( ) {
127
82
var timing = normalizeTimingInput ( {
0 commit comments