@visactor/vgrammar-core
Version:
VGrammar is a visual grammar library
54 lines (49 loc) • 2.17 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.ViewZoom = void 0;
const vutils_1 = require("@visactor/vutils"), view_navigation_base_1 = require("./view-navigation-base");
class ViewZoom extends view_navigation_base_1.ViewNavigationBase {
constructor(view, option) {
super(view, Object.assign({}, ViewZoom.defaultOptions, option)), this.type = ViewZoom.type,
this.handleStartInner = e => {
this.formatZoomEvent(e), !e || this.options.shouldStart && !this.options.shouldStart(e) || (this._inited || this._initGrammars(),
this._isStarted = !0, this.updateView("start", this.handleZoomStart(e, this._state, {
rate: this.options.rate,
focus: this.options.focus
}), "zoom", e));
}, this.handleEnd = e => {
this._isStarted && (this.formatZoomEvent(e), !e || this.options.shouldEnd && !this.options.shouldEnd(e) || this.updateView("end", this.handleZoomEnd(e, this._state, {
rate: this.options.rate,
focus: this.options.focus
}), "zoom", e));
}, this.handleReset = e => {
this._isStarted && (!e || this.options.shouldReset && !this.options.shouldReset(e) || (this.updateView("reset", this.handleZoomReset(e, this._state, {
rate: this.options.rate,
focus: this.options.focus
}), "zoom", 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
}, {
type: this.options.triggerOff,
handler: this.handleReset
} ];
}
}
exports.ViewZoom = ViewZoom, ViewZoom.type = "view-zoom", ViewZoom.defaultOptions = {
realtime: !0,
focus: !0,
trigger: "wheel",
endTrigger: "pointerup",
triggerOff: "dblclick",
rate: 1,
throttle: 100
};
//# sourceMappingURL=view-zoom.js.map