mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-13 16:44:49 +08:00
35 lines
1003 B
JavaScript
Executable File
35 lines
1003 B
JavaScript
Executable File
import Configuration from "../../Configuration.js"
|
|
import IMouseWheel from "./IMouseWheel.js"
|
|
|
|
export default class Zoom extends IMouseWheel {
|
|
|
|
#accumulatedVariation = 0
|
|
|
|
#enableZoonIn = false
|
|
get enableZoonIn() {
|
|
return this.#enableZoonIn
|
|
}
|
|
set enableZoonIn(value) {
|
|
if (value == this.#enableZoonIn) {
|
|
return
|
|
}
|
|
this.#enableZoonIn = value
|
|
}
|
|
|
|
wheel(variation, location) {
|
|
this.#accumulatedVariation += -variation
|
|
variation = this.#accumulatedVariation
|
|
if (Math.abs(this.#accumulatedVariation) < Configuration.mouseWheelZoomThreshold) {
|
|
return
|
|
} else {
|
|
this.#accumulatedVariation = 0
|
|
}
|
|
let zoomLevel = this.blueprint.getZoom()
|
|
if (!this.enableZoonIn && zoomLevel == 0 && variation > 0) {
|
|
return
|
|
}
|
|
zoomLevel += Math.sign(variation)
|
|
this.blueprint.setZoom(zoomLevel, location)
|
|
}
|
|
}
|