feat(animation): cubic-bezier easing conversion utility (experimental) (#19788)

resolves #19789
This commit is contained in:
Liam DeBeasi
2019-10-31 10:16:33 -04:00
committed by GitHub
parent 33cf08bf0e
commit 96a5e600e5
7 changed files with 84 additions and 54 deletions

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Animation, createAnimation } from '@ionic/core';
import { Animation, createAnimation, getTimeGivenProgression } from '@ionic/core';
@Injectable({
providedIn: 'root',
@ -11,4 +11,22 @@ export class AnimationController {
create(animationId?: string): Animation {
return createAnimation(animationId);
}
/**
* EXPERIMENTAL
*
* Given a progression and a cubic bezier function,
* this utility returns the time value(s) at which the
* cubic bezier reaches the given time progression.
*
* If the cubic bezier never reaches the progression
* the result will be an empty array.
*
* This is most useful for switching between easing curves
* when doing a gesture animation (i.e. going from linear easing
* during a drag, to another easing when `progressEnd` is called)
*/
easingTime(p0: number[], p1: number[], p2: number[], p3: number[], progression: number): number[] {
return getTimeGivenProgression(p0, p1, p2, p3, progression);
}
}