UNPKG

vscroll

Version:
64 lines 2.3 kB
import { __assign, __extends } from "tslib"; import { BaseProcessFactory, CommonProcess, ProcessStatus } from './misc/index'; var isInterrupted = function (_a) { var call = _a.call; return !!call.interrupted; }; var End = /** @class */ (function (_super) { __extends(End, _super); function End() { return _super !== null && _super.apply(this, arguments) || this; } End.run = function (scroller, _a) { var _b = _a === void 0 ? {} : _a, error = _b.error; var workflow = scroller.workflow, interrupter = scroller.state.cycle.interrupter; if (!error && !interrupter) { // set out params accessible via Adapter End.calculateParams(scroller); } // explicit interruption for we don't want to go through the inner loop finalizing if (isInterrupted(workflow)) { workflow.call({ process: End.process, status: ProcessStatus.done }); return; } var next = End.shouldContinueRun(scroller, error); scroller.state.endInnerLoop(); workflow.call({ process: End.process, status: next ? ProcessStatus.next : ProcessStatus.done, payload: __assign({}, (interrupter ? { process: interrupter } : {})) }); }; End.calculateParams = function (scroller) { var adapter = scroller.adapter, workflow = scroller.workflow; adapter.setFirstOrLastVisible({ first: true, workflow: workflow }); adapter.setFirstOrLastVisible({ last: true, workflow: workflow }); }; End.shouldContinueRun = function (scroller, error) { var _a = scroller.state, cycle = _a.cycle, fetch = _a.fetch, render = _a.render; // Adapter.reload or Adapter.reset if (cycle.interrupter) { return true; } // critical error if (error) { return false; } // Adapter.check if (fetch.simulate && fetch.isCheck && !render.noSize) { return true; } // Adapter.remove or Adapter.update with clip if (fetch.simulate && fetch.doRemove) { return true; } // common inner loop (App start, scroll, Adapter.clip) with full fetch if (!fetch.simulate && ((fetch.hasNewItems && !render.noSize) || fetch.hasAnotherPack)) { return true; } return false; }; return End; }(BaseProcessFactory(CommonProcess.end))); export default End; //# sourceMappingURL=end.js.map