From 493a2108e91bc003735e19541cd885b85011010d Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Tue, 5 Mar 2024 20:53:54 +0200 Subject: [PATCH] fix safari builder scaling --- app/javascript/template_builder/area.vue | 10 +++++----- app/javascript/template_builder/page.vue | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue index 6ce118b4..931f69c4 100644 --- a/app/javascript/template_builder/area.vue +++ b/app/javascript/template_builder/area.vue @@ -343,7 +343,7 @@ export default { }, onResizeCell (e) { if (e.target.id === 'mask') { - const positionX = e.layerX / (e.target.clientWidth - 1) + const positionX = e.offsetX / (e.target.clientWidth - 1) if (positionX > this.area.x) { this.area.cell_w = positionX - this.area.x @@ -389,16 +389,16 @@ export default { }, resize (e) { if (e.target.id === 'mask') { - this.area.w = e.layerX / e.target.clientWidth - this.area.x - this.area.h = e.layerY / e.target.clientHeight - this.area.y + this.area.w = e.offsetX / e.target.clientWidth - this.area.x + this.area.h = e.offsetY / e.target.clientHeight - this.area.y } }, drag (e) { if (e.target.id === 'mask') { this.isDragged = true - this.area.x = (e.layerX - this.dragFrom.x) / e.target.clientWidth - this.area.y = (e.layerY - this.dragFrom.y) / e.target.clientHeight + this.area.x = (e.offsetX - this.dragFrom.x) / e.target.clientWidth + this.area.y = (e.offsetY - this.dragFrom.y) / e.target.clientHeight } }, startDrag (e) { diff --git a/app/javascript/template_builder/page.vue b/app/javascript/template_builder/page.vue index 0da13943..a97d8fbf 100644 --- a/app/javascript/template_builder/page.vue +++ b/app/javascript/template_builder/page.vue @@ -162,8 +162,8 @@ export default { }, onDrop (e) { this.$emit('drop-field', { - x: e.layerX, - y: e.layerY, + x: e.offsetX, + y: e.offsetY, maskW: this.$refs.mask.clientWidth, maskH: this.$refs.mask.clientHeight, page: this.number @@ -186,10 +186,10 @@ export default { this.$nextTick(() => { this.newArea = { - initialX: e.layerX / this.$refs.mask.clientWidth, - initialY: e.layerY / this.$refs.mask.clientHeight, - x: e.layerX / this.$refs.mask.clientWidth, - y: e.layerY / this.$refs.mask.clientHeight, + initialX: e.offsetX / this.$refs.mask.clientWidth, + initialY: e.offsetY / this.$refs.mask.clientHeight, + x: e.offsetX / this.$refs.mask.clientWidth, + y: e.offsetY / this.$refs.mask.clientHeight, w: 0, h: 0 } @@ -197,19 +197,19 @@ export default { }, onPointermove (e) { if (this.newArea) { - const dx = e.layerX / this.$refs.mask.clientWidth - this.newArea.initialX - const dy = e.layerY / this.$refs.mask.clientHeight - this.newArea.initialY + const dx = e.offsetX / this.$refs.mask.clientWidth - this.newArea.initialX + const dy = e.offsetY / this.$refs.mask.clientHeight - this.newArea.initialY if (dx > 0) { this.newArea.x = this.newArea.initialX } else { - this.newArea.x = e.layerX / this.$refs.mask.clientWidth + this.newArea.x = e.offsetX / this.$refs.mask.clientWidth } if (dy > 0) { this.newArea.y = this.newArea.initialY } else { - this.newArea.y = e.layerY / this.$refs.mask.clientHeight + this.newArea.y = e.offsetY / this.$refs.mask.clientHeight } if (this.drawField?.type === 'cells') {