vevet
Version:
Vevet is a JavaScript library for creative development that simplifies crafting rich interactions like split text animations, carousels, marquees, preloading, and more.
74 lines • 2.81 kB
JavaScript
;
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.SnapInterval = void 0;
var isFiniteNumber_1 = require("../../../../internal/isFiniteNumber");
var __1 = require("..");
var SnapInterval = /** @class */ (function (_super) {
__extends(SnapInterval, _super);
function SnapInterval(ctx, _onPrev, _onNext) {
var _this = _super.call(this, ctx) || this;
_this._onPrev = _onPrev;
_this._onNext = _onNext;
_this.callbacks.on('update', function () { return _this._handleUpdate(); }, {
protected: true,
});
_this.addDestructor(function () { return _this._clearInterval(); });
return _this;
}
Object.defineProperty(SnapInterval.prototype, "allowInterval", {
get: function () {
return (!this.isSwiping &&
!this.hasInertia &&
!this.isTransitioning &&
!this.isInterpolating &&
(0, isFiniteNumber_1.isFiniteNumber)(this.props.interval));
},
enumerable: false,
configurable: true
});
/** Handle Snap update */
SnapInterval.prototype._handleUpdate = function () {
var _this = this;
if (!this.allowInterval) {
this._clearInterval();
return;
}
if (!this._interval) {
this._interval = setInterval(function () { return _this._handleInterval(); }, this.props.interval);
}
};
/** Handle interval action */
SnapInterval.prototype._handleInterval = function () {
if (this.props.intervalDirection === 'prev') {
this._onPrev();
}
else {
this._onNext();
}
};
/** Clear interval */
SnapInterval.prototype._clearInterval = function () {
if (this._interval) {
clearInterval(this._interval);
this._interval = undefined;
}
};
return SnapInterval;
}(__1.SnapLogic));
exports.SnapInterval = SnapInterval;
//# sourceMappingURL=index.js.map