MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / play

Function play

core/src/utils/animation/animation.ts:829–891  ·  view source on GitHub ↗
(opts?: AnimationPlayOptions)

Source from the content-addressed store, hash-verified

827 };
828
829 const play = (opts?: AnimationPlayOptions) => {
830 return new Promise<void>((resolve) => {
831 if (opts?.sync) {
832 shouldForceSyncPlayback = true;
833
834 onFinish(() => (shouldForceSyncPlayback = false), { oneTimeCallback: true });
835 }
836 if (!initialized) {
837 initializeAnimation();
838 }
839
840 if (finished) {
841 resetAnimation();
842 finished = false;
843 }
844
845 if (shouldCalculateNumAnimations) {
846 numAnimationsRunning = childAnimations.length + 1;
847 shouldCalculateNumAnimations = false;
848 }
849
850 /**
851 * When one of these callbacks fires we
852 * need to clear the other's callback otherwise
853 * you can potentially get these callbacks
854 * firing multiple times if the play method
855 * is subsequently called.
856 * Example:
857 * animation.play() (onStop and onFinish callbacks are registered)
858 * animation.stop() (onStop callback is fired, onFinish is not)
859 * animation.play() (onStop and onFinish callbacks are registered)
860 * Total onStop callbacks: 1
861 * Total onFinish callbacks: 2
862 */
863 const onStopCallback = () => {
864 clearCallback(onFinishCallback, onFinishOneTimeCallbacks);
865 resolve();
866 };
867 const onFinishCallback = () => {
868 clearCallback(onStopCallback, onStopOneTimeCallbacks);
869 resolve();
870 };
871
872 /**
873 * The play method resolves when an animation
874 * run either finishes or is cancelled.
875 */
876 onFinish(onFinishCallback, { oneTimeCallback: true });
877 onStop(onStopCallback, { oneTimeCallback: true });
878
879 childAnimations.forEach((animation) => {
880 animation.play();
881 });
882
883 if (supportsWebAnimations) {
884 playWebAnimations();
885 } else {
886 playCSSAnimations();

Callers 1

progressEndFunction · 0.85

Calls 7

onFinishFunction · 0.85
initializeAnimationFunction · 0.85
resetAnimationFunction · 0.85
onStopFunction · 0.85
playWebAnimationsFunction · 0.85
playCSSAnimationsFunction · 0.85
playMethod · 0.80

Tested by

no test coverage detected