UNPKG

vscroll

Version:
70 lines 2.29 kB
import { __assign } from "tslib"; import { Reactive } from './reactive'; import { WorkflowCycleModel } from './state/cycle'; import { FetchModel } from './state/fetch'; import { ClipModel } from './state/clip'; import { RenderModel } from './state/render'; import { ScrollModel } from './state/scroll'; var State = /** @class */ (function () { function State(packageInfo, settings, state) { this.packageInfo = packageInfo; this.settings = settings; this.initTime = Number(new Date()); this.paused = new Reactive(false); this.cycle = new WorkflowCycleModel(this.settings.instanceIndex, state ? state.cycle : void 0); this.fetch = new FetchModel(settings.directionPriority); this.clip = new ClipModel(); this.render = new RenderModel(); this.scroll = new ScrollModel(); } Object.defineProperty(State.prototype, "time", { get: function () { return Number(new Date()) - this.initTime; }, enumerable: false, configurable: true }); State.prototype.startWorkflowCycle = function (isInitial, initiator) { this.cycle.start(isInitial, initiator); }; State.prototype.endWorkflowCycle = function (count) { this.cycle.end(count); }; State.prototype.startInnerLoop = function () { var _a = this, cycle = _a.cycle, scroll = _a.scroll, fetch = _a.fetch, render = _a.render, clip = _a.clip; cycle.innerLoop.start(); scroll.positionBeforeAsync = null; if (!fetch.simulate) { fetch.reset(); } clip.reset(clip.force); render.reset(); return __assign({}, (cycle.innerLoop.first ? { process: cycle.initiator, doRender: fetch.simulate && fetch.items.length > 0 } : {})); }; State.prototype.endInnerLoop = function () { var _a = this, fetch = _a.fetch, clip = _a.clip, render = _a.render, cycle = _a.cycle; fetch.stopSimulate(); clip.reset(true); if (fetch.cancel) { fetch.cancel(); fetch.cancel = null; } if (render.cancel) { render.cancel(); render.cancel = null; } cycle.innerLoop.done(); }; State.prototype.dispose = function () { this.scroll.stop(); this.cycle.dispose(); this.paused.dispose(); this.endInnerLoop(); }; return State; }()); export { State }; //# sourceMappingURL=state.js.map