diff --git a/js/UEBlueprint.js b/js/UEBlueprint.js index 2ca1afd..d16e78d 100644 --- a/js/UEBlueprint.js +++ b/js/UEBlueprint.js @@ -246,13 +246,6 @@ export default class UEBlueprint extends HTMLElement { if (center) { - - let point = document.createElement('div'); - point.style.width = '2px' - point.style.height = '2px' - point.style.background = 'red' - point.style.position = 'absolute' - document.querySelector('.ueb-grid').appendChild(point) let relativeScale = this.getScale() / initialScale let newCenter = [ relativeScale * center[0], @@ -262,8 +255,6 @@ export default class UEBlueprint extends HTMLElement { (newCenter[0] - center[0]) * initialScale, (newCenter[1] - center[1]) * initialScale ]) - point.style.left = `${center[0]}px` - point.style.top = `${center[1]}px` } } diff --git a/js/UEBlueprintDragScroll.js b/js/UEBlueprintDragScroll.js index ebfcc50..7e56a31 100644 --- a/js/UEBlueprintDragScroll.js +++ b/js/UEBlueprintDragScroll.js @@ -21,11 +21,10 @@ export default class UEBlueprintDragScroll extends UEBlueprintDrag { e.preventDefault() let zoomLevel = self.blueprintNode.getZoom() zoomLevel -= Math.sign(e.deltaY) - let scale = self.blueprintNode.getScale() + let scaleCorrection = 1 / self.blueprintNode.getScale() const targetOffset = e.target.getBoundingClientRect() const currentTargetOffset = e.currentTarget.getBoundingClientRect() - let offset = [e.offsetX + targetOffset.x - currentTargetOffset.x, e.offsetY + targetOffset.y - currentTargetOffset.y] - console.log([offset[0] - e.x, offset[1] - e.y]) + let offset = [e.offsetX + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, e.offsetY + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection] self.blueprintNode.setZoom(zoomLevel, offset) } diff --git a/ueblueprint.js b/ueblueprint.js index 7ea42cb..635f2ba 100644 --- a/ueblueprint.js +++ b/ueblueprint.js @@ -87,11 +87,10 @@ class UEBlueprintDragScroll extends UEBlueprintDrag { e.preventDefault(); let zoomLevel = self.blueprintNode.getZoom(); zoomLevel -= Math.sign(e.deltaY); - self.blueprintNode.getScale(); + let scaleCorrection = 1 / self.blueprintNode.getScale(); const targetOffset = e.target.getBoundingClientRect(); const currentTargetOffset = e.currentTarget.getBoundingClientRect(); - let offset = [e.offsetX + targetOffset.x - currentTargetOffset.x, e.offsetY + targetOffset.y - currentTargetOffset.y]; - console.log([offset[0] - e.x, offset[1] - e.y]); + let offset = [e.offsetX + targetOffset.x * scaleCorrection - currentTargetOffset.x * scaleCorrection, e.offsetY + targetOffset.y * scaleCorrection - currentTargetOffset.y * scaleCorrection]; self.blueprintNode.setZoom(zoomLevel, offset); }; @@ -352,13 +351,6 @@ class UEBlueprint extends HTMLElement { if (center) { - - let point = document.createElement('div'); - point.style.width = '2px'; - point.style.height = '2px'; - point.style.background = 'red'; - point.style.position = 'absolute'; - document.querySelector('.ueb-grid').appendChild(point); let relativeScale = this.getScale() / initialScale; let newCenter = [ relativeScale * center[0], @@ -368,8 +360,6 @@ class UEBlueprint extends HTMLElement { (newCenter[0] - center[0]) * initialScale, (newCenter[1] - center[1]) * initialScale ]); - point.style.left = `${center[0]}px`; - point.style.top = `${center[1]}px`; } }