Sha256: 4e793b5463c9db972a8ab4921cea93d59dfacc99ecd9e723215135af5fee35a4

Contents?: true

Size: 1.97 KB

Versions: 49

Compression:

Stored size: 1.97 KB

Contents

import { AsyncAction } from './AsyncAction';
import { AnimationFrame } from '../util/AnimationFrame';
/**
 * We need this JSDoc comment for affecting ESDoc.
 * @ignore
 * @extends {Ignored}
 */
export class AnimationFrameAction extends AsyncAction {
    constructor(scheduler, work) {
        super(scheduler, work);
        this.scheduler = scheduler;
        this.work = work;
    }
    requestAsyncId(scheduler, id, delay = 0) {
        // If delay is greater than 0, request as an async action.
        if (delay !== null && delay > 0) {
            return super.requestAsyncId(scheduler, id, delay);
        }
        // Push the action to the end of the scheduler queue.
        scheduler.actions.push(this);
        // If an animation frame has already been requested, don't request another
        // one. If an animation frame hasn't been requested yet, request one. Return
        // the current animation frame request id.
        return scheduler.scheduled || (scheduler.scheduled = AnimationFrame.requestAnimationFrame(scheduler.flush.bind(scheduler, null)));
    }
    recycleAsyncId(scheduler, id, delay = 0) {
        // If delay exists and is greater than 0, or if the delay is null (the
        // action wasn't rescheduled) but was originally scheduled as an async
        // action, then recycle as an async action.
        if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
            return super.recycleAsyncId(scheduler, id, delay);
        }
        // If the scheduler queue is empty, cancel the requested animation frame and
        // set the scheduled flag to undefined so the next AnimationFrameAction will
        // request its own.
        if (scheduler.actions.length === 0) {
            AnimationFrame.cancelAnimationFrame(id);
            scheduler.scheduled = undefined;
        }
        // Return undefined so the action knows to request a new async id if it's rescheduled.
        return undefined;
    }
}
//# sourceMappingURL=AnimationFrameAction.js.map

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
ilog-0.4.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
ilog-0.3.3 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-18.0.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.21.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.20.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.19.1 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.19.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.18.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.17.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.16.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.15.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.14.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.13.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.12.2 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.12.1 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.12.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.11.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.10.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js
govuk_publishing_components-17.9.0 node_modules/rxjs/_esm2015/scheduler/AnimationFrameAction.js