@@ -111,7 +111,8 @@ public static function EaseInOutExpo(string $time): string
111
111
$ firstExp = "pow(2 \\,20*( {$ time })-10)/2 " ;
112
112
$ secondExp = "(2-pow(2 \\,-20*( {$ time })+10))/2 " ;
113
113
114
- return "if(eq(( {$ time }) \\,0) \\,0 \\,(if(eq(( {$ time }) \\,1) \\,1 \\,if(lt(( {$ time }) \\,0.5) \\,pow(2 \\,20*( {$ firstExp })-10)/2) \\,(2-pow(2 \\,-20*( {$ secondExp })+10))/2))) " ;
114
+ // We have to set the return value for 0 and 1 explicitly as we lose accuracy at the 4th decimal place.
115
+ return "if(eq(( {$ time }) \\,0) \\,0 \\,if(eq(( {$ time }) \\,1) \\,1 \\,if(lt(( {$ time }) \\,0.5) \\, {$ firstExp }\\, {$ secondExp }))) " ;
115
116
}
116
117
117
118
public static function EaseInCirc (string $ time ): string
@@ -134,7 +135,7 @@ public static function EaseInBack(string $time): string
134
135
$ c1 = 1.70158 ;
135
136
$ c3 = $ c1 + 1 ;
136
137
137
- return "{$ c1 }*pow(( {$ time }) \\,3)- {$ c3 }*pow(( {$ time }) \\,2) " ;
138
+ return "{$ c3 }*pow(( {$ time }) \\,3)- {$ c1 }*pow(( {$ time }) \\,2) " ;
138
139
}
139
140
140
141
public static function EaseOutBack (string $ time ): string
@@ -157,7 +158,7 @@ public static function EaseInElastic(string $time): string
157
158
{
158
159
$ c4 = (2 * M_PI ) / 3 ;
159
160
160
- return "if(eq(( {$ time }) \\,0) \\,0 \\,if(eq(( {$ time }) \\,1) \\,1 \\,-pow(2 \\,10*( {$ time })-10)*sin(( {$ time })*10-10.75)* {$ c4 })) " ;
161
+ return "if(eq(( {$ time }) \\,0) \\,0 \\,if(eq(( {$ time }) \\,1) \\,1 \\,-pow(2 \\,10*( {$ time })-10)*sin((( {$ time })*10-10.75)* {$ c4 }) )) " ;
161
162
}
162
163
163
164
public static function EaseOutElastic (string $ time ): string
@@ -188,12 +189,12 @@ public static function EaseOutBounce(string $time): string
188
189
$ n1 = 7.5625 ;
189
190
$ d1 = 2.75 ;
190
191
$ firstExpr = "{$ n1 }*pow(( {$ time }) \\,2) " ;
191
- $ secondTime = "(( {$ time })-1.5) " ;
192
- $ secondExpr = "{$ n1 }*( {$ secondTime }/ { $ d1 } )*( {$ secondTime }) +0.75 " ;
193
- $ thirdTime = "(( {$ time })-2.25) " ;
194
- $ thirdExpr = "{$ n1 }*( {$ thirdTime }/ { $ d1 } )*( {$ thirdTime }) +0.9375 " ;
195
- $ fourthTime = "(( {$ time })-2.65) " ;
196
- $ fourthExpr = "{$ n1 }*( {$ fourthTime }/ { $ d1 } )*( {$ fourthTime }) +0.984375 " ;
192
+ $ secondTime = "(( {$ time })-1.5/ { $ d1 } ) " ;
193
+ $ secondExpr = "{$ n1 }* {$ secondTime }* {$ secondTime }+0.75 " ;
194
+ $ thirdTime = "(( {$ time })-2.25/ { $ d1 } ) " ;
195
+ $ thirdExpr = "{$ n1 }* {$ thirdTime }* {$ thirdTime }+0.9375 " ;
196
+ $ fourthTime = "(( {$ time })-2.65/ { $ d1 } ) " ;
197
+ $ fourthExpr = "{$ n1 }* {$ fourthTime }* {$ fourthTime }+0.984375 " ;
197
198
198
199
return "if(lt(( {$ time }) \\, 1/ {$ d1 }) \\, {$ firstExpr }\\,if(lt(( {$ time }) \\,2/ {$ d1 }) \\, {$ secondExpr }\\,if(lt(( {$ time }) \\,2.5/ {$ d1 }) \\, {$ thirdExpr }\\, {$ fourthExpr }))) " ;
199
200
}
@@ -202,9 +203,9 @@ public static function EaseInOutBounce(string $time): string
202
203
{
203
204
$ x1 = self ::EaseOutBounce ("1-2*( {$ time }) " );
204
205
$ x2 = self ::EaseOutBounce ("2*( {$ time })-1 " );
205
- $ gtExpr = "(1-( {$ x1 }))/2 " ;
206
- $ ltExpr = "(1+( {$ x2 }))/2 " ;
206
+ $ ltExpr = "(1-( {$ x1 }))/2 " ;
207
+ $ gtExpr = "(1+( {$ x2 }))/2 " ;
207
208
208
- return "if(lt(( {$ time }) \\,0.5) \\, {$ ltExpr }\\, {$ gtExpr }" ;
209
+ return "if(lt(( {$ time }) \\,0.5) \\, {$ ltExpr }\\, {$ gtExpr }) " ;
209
210
}
210
211
}
0 commit comments