UNPKG

animatable-js

Version:

This package allows easy and light implementation of linear or curved animation in javascript. (Especially suitable in a development environment on web components or canvas.)

28 lines (26 loc) 824 B
import { TickerBinding } from "./ticker_binding"; import { TickerCallback } from "./types"; /** * This class is essential to implementing animation. * * Used to define a elapsed duration between a previous frame and * the current frame when a frame updated. * * Used by `Animation` class. */ export class Ticker { /** * When an instance is created by this constructor, a related task * is performed immediately. * * See also: * @important A dispose() must be called after the ticker is used. */ constructor(public callback: TickerCallback) { TickerBinding.instance.addListener(callback); } /** Cancels the registered animation frame listener. */ dispose() { TickerBinding.instance.removeListener(this.callback); } }