UNPKG

@lanaqi/rsr-nprogress

Version:
43 lines (42 loc) 1.48 kB
import * as __WEBPACK_EXTERNAL_MODULE__lanaqi_rsr_f549445f__ from "@lanaqi/rsr"; import * as __WEBPACK_EXTERNAL_MODULE_nprogress__ from "nprogress"; import "nprogress/nprogress.css"; class NProgressAddon extends __WEBPACK_EXTERNAL_MODULE__lanaqi_rsr_f549445f__.AbstractAddon { progress; timeout; clear; constructor(progress, timeout){ super(); this.progress = progress; this.timeout = timeout; this.clear = void 0; } guardBefore(context, manager, currentPath, currentResource) { if (!this.progress.isStarted()) { this.progress.start(); if (this.clear) clearTimeout(this.clear); this.clear = setTimeout(()=>{ if (this.progress.isStarted()) this.progress.done(); }, this.timeout); } } guardAfter(context, manager, currentPath, currentResource, currentDecision) { if (this.progress.isStarted()) this.progress.done(); if (this.clear) { clearTimeout(this.clear); this.clear = void 0; } } } const nProgressAddon = (config, timeout = 15000)=>{ let options; options = config ? config : { showSpinner: false, easing: 'ease', speed: 200, trickleSpeed: 100 }; const progress = __WEBPACK_EXTERNAL_MODULE_nprogress__["default"].configure(options); return new NProgressAddon(progress, timeout); }; export { NProgressAddon, nProgressAddon };