MCPcopy Index your code
hub / github.com/ampproject/amphtml / complete_

Method complete_

src/utils/animation.js:241–275  ·  view source on GitHub ↗

* @param {boolean} success * @param {number} dir * @private

(success, dir)

Source from the content-addressed store, hash-verified

239 * @private
240 */
241 complete_(success, dir) {
242 if (!this.running_) {
243 return;
244 }
245 this.running_ = false;
246 if (dir != 0) {
247 // Sort in the completion order.
248 if (this.segments_.length > 1) {
249 this.segments_.sort((s1, s2) => {
250 return s1.delay + s1.duration - (s2.delay + s2.duration);
251 });
252 }
253 try {
254 if (dir > 0) {
255 // Natural order - all set to 1.
256 for (let i = 0; i < this.segments_.length; i++) {
257 this.segments_[i].func(1, true);
258 }
259 } else {
260 // Reverse order - all set to 0.
261 for (let i = this.segments_.length - 1; i >= 0; i--) {
262 this.segments_[i].func(0, false);
263 }
264 }
265 } catch (e) {
266 dev().error(TAG_, 'completion failed: ' + e, e);
267 success = false;
268 }
269 }
270 if (success) {
271 this.resolve_();
272 } else {
273 this.reject_();
274 }
275 }
276
277 /**
278 * @param {!{[key: string]: *}} unusedState

Callers 4

constructorMethod · 0.95
haltMethod · 0.95
stepMutate_Method · 0.95
mutateSegment_Method · 0.95

Calls 3

devFunction · 0.90
resolve_Method · 0.80
errorMethod · 0.45

Tested by

no test coverage detected