@visactor/vgrammar-core
Version:
VGrammar is a visual grammar library
35 lines (31 loc) • 1.43 kB
JavaScript
import { throttle } from "@visactor/vutils";
import { ViewNavigationBase } from "./view-navigation-base";
export class ViewScroll extends ViewNavigationBase {
constructor(view, option) {
super(view, Object.assign({}, ViewScroll.defaultOptions, option)), this.type = ViewScroll.type,
this.handleStartInner = e => {
this.formatScrollEvent(e), !e || this.options.shouldStart && !this.options.shouldStart(e) || (this._isStarted = !0,
this._inited || this._initGrammars(), this.updateView("start", this.handleScrollStart(e, this._state, this.options), "scroll", e));
}, this.handleEnd = e => {
this._isStarted && (this.formatScrollEvent(e), !e || this.options.shouldEnd && !this.options.shouldEnd(e) || (this.updateView("end", this.handleScrollEnd(e, this._state, this.options), "scroll", e),
this._isStarted = !1));
}, this.handleStart = throttle(this.handleStartInner, this.options.throttle);
}
getEvents() {
return [ {
type: this.options.trigger,
handler: this.handleStart
}, {
type: this.options.endTrigger,
handler: this.handleEnd
} ];
}
}
ViewScroll.type = "view-scroll", ViewScroll.defaultOptions = {
realtime: !0,
reversed: !1,
trigger: "wheel",
endTrigger: "pointerup",
throttle: 100
};
//# sourceMappingURL=view-scroll.js.map