MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / constructor

Method constructor

packages/core/ui/animation/index.ios.ts:149–197  ·  view source on GitHub ↗
(animationDefinitions: Array<AnimationDefinitionInternal>, playSequentially?: boolean)

Source from the content-addressed store, hash-verified

147 private _valueSource: 'animation' | 'keyframe';
148
149 constructor(animationDefinitions: Array<AnimationDefinitionInternal>, playSequentially?: boolean) {
150 super(animationDefinitions, playSequentially);
151
152 this._valueSource = 'animation';
153 if (animationDefinitions.length > 0 && animationDefinitions[0].valueSource !== undefined) {
154 this._valueSource = animationDefinitions[0].valueSource;
155 }
156
157 if (!playSequentially) {
158 if (Trace.isEnabled()) {
159 Trace.write('Non-merged Property Animations: ' + this._propertyAnimations.length, Trace.categories.Animation);
160 }
161 this._mergedPropertyAnimations = Animation._mergeAffineTransformAnimations(this._propertyAnimations);
162 if (Trace.isEnabled()) {
163 Trace.write('Merged Property Animations: ' + this._mergedPropertyAnimations.length, Trace.categories.Animation);
164 }
165 } else {
166 this._mergedPropertyAnimations = this._propertyAnimations;
167 }
168
169 const animationFinishedCallback = (cancelled: boolean) => {
170 if (this._playSequentially) {
171 // This function will be called by the last animation when done or by another animation if the user cancels them halfway through.
172 if (!cancelled) {
173 this._resolveAnimationFinishedPromise();
174 }
175 } else {
176 // This callback will be called by each INDIVIDUAL animation when it finishes or is cancelled.
177 if (cancelled) {
178 this._cancelledAnimations++;
179 } else {
180 this._finishedAnimations++;
181 }
182
183 if (this._cancelledAnimations > 0 && this._cancelledAnimations + this._finishedAnimations === this._mergedPropertyAnimations.length) {
184 if (Trace.isEnabled()) {
185 Trace.write(this._cancelledAnimations + ' animations cancelled.', Trace.categories.Animation);
186 }
187 } else if (this._finishedAnimations === this._mergedPropertyAnimations.length) {
188 if (Trace.isEnabled()) {
189 Trace.write(this._finishedAnimations + ' animations finished.', Trace.categories.Animation);
190 }
191 this._resolveAnimationFinishedPromise();
192 }
193 }
194 };
195
196 this._iOSAnimationFunction = Animation._createiOSAnimationFunction(this._mergedPropertyAnimations, 0, this._playSequentially, this._valueSource, animationFinishedCallback);
197 }
198
199 public play(): AnimationPromise {
200 if (this.isPlaying) {

Callers

nothing calls this directly

Calls 4

isEnabledMethod · 0.80
writeMethod · 0.65

Tested by

no test coverage detected