MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / animate

Method animate

packages/core/ui/gestures/touch-manager.ts:183–219  ·  view source on GitHub ↗
(definition: AnimationDefinition | TouchAnimationFn)

Source from the content-addressed store, hash-verified

181 static startAnimationForType(view: View, type: TouchAnimationTypes) {
182 if (view) {
183 const animate = function (definition: AnimationDefinition | TouchAnimationFn) {
184 if (definition) {
185 if (isFunction(definition)) {
186 (<TouchAnimationFn>definition)(view);
187 } else {
188 if (!TouchManager.touchAnimationDefinitions) {
189 TouchManager.touchAnimationDefinitions = [];
190 }
191 // reuse animations for each type
192 let touchAnimation: Animation;
193 // triggering animations should always cancel other animations which may be in progress
194 for (const d of TouchManager.touchAnimationDefinitions) {
195 if (d.view === view && d.animation) {
196 d.animation.cancel();
197 if (d.type === type) {
198 touchAnimation = d.animation;
199 }
200 }
201 }
202
203 if (!touchAnimation) {
204 touchAnimation = new Animation([
205 {
206 target: view,
207 ...(<AnimationDefinition>definition),
208 },
209 ]);
210 TouchManager.touchAnimationDefinitions.push({
211 view,
212 type,
213 animation: touchAnimation,
214 });
215 }
216 touchAnimation.play().catch(() => {});
217 }
218 }
219 };
220 // always use instance defined animation over global
221 if (isObject(view.touchAnimation) && view.touchAnimation[type]) {
222 animate(view.touchAnimation[type]);

Callers 15

toggleAnimationMethod · 0.45
shakeItMethod · 0.45
shiftAwayMethod · 0.45
shiftBackMethod · 0.45
test_AnimatingPropertiesFunction · 0.45
test_CancellingAnimateFunction · 0.45
test_ChainingAnimationsFunction · 0.45
test_AnimateOpacityFunction · 0.45

Calls 4

isFunctionFunction · 0.90
cancelMethod · 0.65
playMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected