UNPKG

vevet

Version:

Vevet is a JavaScript library for creative development that simplifies crafting rich interactions like split text animations, carousels, marquees, preloading, and more.

40 lines 1.07 kB
import { SnapLogic } from '../SnapLogic'; export class SnapIdle extends SnapLogic { constructor(snap) { super(snap); snap.on('update', () => this._handleUpdate(), { protected: true }); this.addDestructor(() => { this._clear(); }); } /** Check if idle */ get isIdle() { const { snap } = this; if (snap.isSwiping || snap.isInterpolating || snap.isTransitioning) { return false; } return true; } /** Handle Snap update */ _handleUpdate() { this._clear(); this._timeout = setTimeout(() => { this._handleTimeout(); }, 10); } /** Handle timeout action */ _handleTimeout() { const { snap } = this; if (this.isIdle) { snap.callbacks.emit('idle', undefined); } } /** Clear timeout reference */ _clear() { if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined; } } } //# sourceMappingURL=index.js.map