1 | 'use strict';
|
2 | import { shouldBeUseWeb } from './PlatformChecker';
|
3 | import {
|
4 | configureLayoutAnimationBatch,
|
5 | makeShareableCloneRecursive,
|
6 | } from './core';
|
7 | import type {
|
8 | LayoutAnimationFunction,
|
9 | LayoutAnimationType,
|
10 | } from './layoutReanimation';
|
11 | import type {
|
12 | LayoutAnimationBatchItem,
|
13 | ProgressAnimationCallback,
|
14 | SharedTransitionAnimationsFunction,
|
15 | } from './layoutReanimation/animationBuilder/commonTypes';
|
16 |
|
17 | function createUpdateManager() {
|
18 | const animations: LayoutAnimationBatchItem[] = [];
|
19 |
|
20 |
|
21 |
|
22 | const deferredAnimations: LayoutAnimationBatchItem[] = [];
|
23 |
|
24 | return {
|
25 | update(batchItem: LayoutAnimationBatchItem, isUnmounting?: boolean) {
|
26 | if (isUnmounting) {
|
27 | deferredAnimations.push(batchItem);
|
28 | } else {
|
29 | animations.push(batchItem);
|
30 | }
|
31 | if (animations.length + deferredAnimations.length === 1) {
|
32 | setImmediate(this.flush);
|
33 | }
|
34 | },
|
35 | flush(this: void) {
|
36 | configureLayoutAnimationBatch(animations.concat(deferredAnimations));
|
37 | animations.length = 0;
|
38 | deferredAnimations.length = 0;
|
39 | },
|
40 | };
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | export let updateLayoutAnimations: (
|
54 | viewTag: number,
|
55 | type: LayoutAnimationType,
|
56 | config?:
|
57 | | Keyframe
|
58 | | LayoutAnimationFunction
|
59 | | SharedTransitionAnimationsFunction
|
60 | | ProgressAnimationCallback,
|
61 | sharedTransitionTag?: string,
|
62 | isUnmounting?: boolean
|
63 | ) => void;
|
64 |
|
65 | if (shouldBeUseWeb()) {
|
66 | updateLayoutAnimations = () => {
|
67 |
|
68 | };
|
69 | } else {
|
70 | const updateLayoutAnimationsManager = createUpdateManager();
|
71 | updateLayoutAnimations = (
|
72 | viewTag,
|
73 | type,
|
74 | config,
|
75 | sharedTransitionTag,
|
76 | isUnmounting
|
77 | ) =>
|
78 | updateLayoutAnimationsManager.update(
|
79 | {
|
80 | viewTag,
|
81 | type,
|
82 | config: config ? makeShareableCloneRecursive(config) : undefined,
|
83 | sharedTransitionTag,
|
84 | },
|
85 | isUnmounting
|
86 | );
|
87 | }
|