/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
/**
 * Easing functions to use for web animations.
 */
export var Easing;
(function (Easing) {
    Easing["STANDARD"] = "cubic-bezier(0.2, 0, 0, 1)";
    Easing["ACCELERATION"] = "cubic-bezier(0.3, 0, 1, 1)";
    Easing["DECELERATION"] = "cubic-bezier(0, 0, 0, 1)";
    Easing["SHARP"] = "cubic-bezier(0.4, 0, 0.6, 1)";
    Easing["EMPHASIZED_ACCELERATE"] = "cubic-bezier(0.3, 0, 0.8, 0.15)";
    Easing["EMPHASIZED_DECELERATE"] = "cubic-bezier(0.05, 0.7, 0.1, 1)";
})(Easing || (Easing = {}));
/**
 * Creates an `AnimationSignal` that can be used to cancel a previous task.
 *
 * @example
 * class MyClass {
 *   private labelAnimationSignal = createAnimationSignal();
 *
 *   private async animateLabel() {
 *     // Start of the task. Previous tasks will be canceled.
 *     const signal = this.labelAnimationSignal.start();
 *
 *     // Do async work...
 *     if (signal.aborted) {
 *       // Use AbortSignal to check if a request was made to abort after some
 *       // asynchronous work.
 *       return;
 *     }
 *
 *     const animation = this.animate(...);
 *     // Add event listeners to be notified when the task should be canceled.
 *     signal.addEventListener('abort', () => {
 *       animation.cancel();
 *     });
 *
 *     animation.addEventListener('finish', () => {
 *       // Tell the signal that the current task is finished.
 *       this.labelAnimationSignal.finish();
 *     });
 *   }
 * }
 *
 * @return An `AnimationSignal`.
 */
export function createAnimationSignal() {
    // The current animation's AbortController
    let animationAbortController = null;
    return {
        start() {
            // Tell the previous animation to cancel.
            animationAbortController?.abort();
            // Set up a new AbortController for the current animation.
            animationAbortController = new AbortController();
            // Provide the AbortSignal so that the caller can check aborted status
            // and add listeners.
            return animationAbortController.signal;
        },
        finish() {
            animationAbortController = null;
        },
    };
}
//# sourceMappingURL=animation.js.map