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.

67 lines 2.42 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 SnapLogic_1 = require("../SnapLogic"); var SnapIdle = /** @class */ (function (_super) { __extends(SnapIdle, _super); function SnapIdle(snap) { var _this = _super.call(this, snap) || this; snap.on('update', function () { return _this._handleUpdate(); }, { protected: true }); _this.addDestructor(function () { _this._clear(); }); return _this; } Object.defineProperty(SnapIdle.prototype, "isIdle", { /** Check if idle */ get: function () { var snap = this.snap; if (snap.isSwiping || snap.isInterpolating || snap.isTransitioning) { return false; } return true; }, enumerable: false, configurable: true }); /** Handle Snap update */ SnapIdle.prototype._handleUpdate = function () { var _this = this; this._clear(); this._timeout = setTimeout(function () { _this._handleTimeout(); }, 10); }; /** Handle timeout action */ SnapIdle.prototype._handleTimeout = function () { var snap = this.snap; if (this.isIdle) { snap.callbacks.emit('idle', undefined); } }; /** Clear timeout reference */ SnapIdle.prototype._clear = function () { if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined; } }; return SnapIdle; }(SnapLogic_1.SnapLogic)); exports.SnapIdle = SnapIdle; //# sourceMappingURL=index.js.map