Various styling fixes

This commit is contained in:
barsdeveloper
2023-05-21 02:21:52 +02:00
parent cccae45d7a
commit 6ed6d397a5
14 changed files with 80 additions and 42 deletions

View File

@@ -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 */

View File

@@ -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)
}
}