UNPKG

@visactor/vgrammar-core

Version:

VGrammar is a visual grammar library

39 lines (34 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.ViewScroll = void 0; const vutils_1 = require("@visactor/vutils"), view_navigation_base_1 = require("./view-navigation-base"); class ViewScroll extends view_navigation_base_1.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 = (0, vutils_1.throttle)(this.handleStartInner, this.options.throttle); } getEvents() { return [ { type: this.options.trigger, handler: this.handleStart }, { type: this.options.endTrigger, handler: this.handleEnd } ]; } } exports.ViewScroll = ViewScroll, ViewScroll.type = "view-scroll", ViewScroll.defaultOptions = { realtime: !0, reversed: !1, trigger: "wheel", endTrigger: "pointerup", throttle: 100 }; //# sourceMappingURL=view-scroll.js.map