mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-03 23:55:04 +08:00
Various styling fixes
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import Configuration from "../../Configuration.js"
|
||||
import IPointing from "./IPointing.js"
|
||||
|
||||
/** @typedef {import("../../Blueprint.js").default} Blueprint */
|
||||
@@ -9,7 +8,7 @@ export default class IMouseWheel extends IPointing {
|
||||
#mouseWheelHandler = e => {
|
||||
e.preventDefault()
|
||||
const location = this.locationFromEvent(e)
|
||||
this.wheel(Math.sign(e.deltaY * Configuration.mouseWheelFactor), location)
|
||||
this.wheel(e.deltaY, location)
|
||||
}
|
||||
|
||||
/** @param {WheelEvent} e */
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
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
|
||||
@@ -14,12 +17,18 @@ export default class Zoom extends IMouseWheel {
|
||||
}
|
||||
|
||||
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()
|
||||
variation = -variation
|
||||
if (!this.enableZoonIn && zoomLevel == 0 && variation > 0) {
|
||||
return
|
||||
}
|
||||
zoomLevel += variation
|
||||
zoomLevel += Math.sign(variation)
|
||||
this.blueprint.setZoom(zoomLevel, location)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user