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.

66 lines 2.51 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SnapIdle = void 0; var __1 = require(".."); var props_1 = require("../../props"); var SnapIdle = /** @class */ (function (_super) { __extends(SnapIdle, _super); function SnapIdle(ctx) { var _this = _super.call(this, ctx) || this; _this.callbacks.on('update', function () { return _this._handleUpdate(); }, { protected: true, }); _this.addDestructor(function () { return _this._clear(); }); return _this; } Object.defineProperty(SnapIdle.prototype, "isIdle", { /** Check if idle */ get: function () { return (!this.isSwiping && !this.hasInertia && !this.isInterpolating && !this.isTransitioning && !this.isWheeling); }, enumerable: false, configurable: true }); /** Handle Snap update */ SnapIdle.prototype._handleUpdate = function () { var _this = this; this._clear(); var debounce = Math.max(props_1.IDLE_DEBOUNCE, props_1.WHEEL_DEBOUNCE) + 10; this._timeout = setTimeout(function () { return _this._handleTimeout(); }, debounce); }; /** Handle timeout action */ SnapIdle.prototype._handleTimeout = function () { if (this.isIdle) { this.callbacks.emit('idle', undefined); } }; /** Clear timeout reference */ SnapIdle.prototype._clear = function () { if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined; } }; return SnapIdle; }(__1.SnapLogic)); exports.SnapIdle = SnapIdle; //# sourceMappingURL=index.js.map