Compensate drag for scale

This commit is contained in:
barsdeveloper
2021-10-04 00:48:38 +02:00
parent fece3da438
commit 1842e45888
4 changed files with 14 additions and 4 deletions

View File

@@ -24,7 +24,8 @@ export default class UDrag extends UMouseClickDrag {
dragTo(e) {
let mousePosition = this.snapToGrid(e.clientX, e.clientY)
const d = [mousePosition[0] - this.mousePosition[0], mousePosition[1] - this.mousePosition[1]]
let scaleCorrection = 1 / this.target.getScale()
const d = [(mousePosition[0] - this.mousePosition[0]) * scaleCorrection, (mousePosition[1] - this.mousePosition[1]) * scaleCorrection]
if (d[0] == 0 && d[1] == 0) {
return

View File

@@ -23,7 +23,7 @@ export default class UMouseWheel {
if (self.looseTarget) {
/*
* Compensating for having used the mouse wheel over a descendant of the target (the element listened for the 'wheel' event).
* We are interested to get the location relative to the listened target, not the exact target that caused the event.
* We are interested to get the location relative to the listened target, not the descendant target that caused the event.
*/
const targetOffset = e.target.getBoundingClientRect()
const currentTargetOffset = e.currentTarget.getBoundingClientRect()