diff --git a/src/cartographer.js b/src/cartographer.js index 8cf3a14..787a759 100644 --- a/src/cartographer.js +++ b/src/cartographer.js @@ -65,7 +65,10 @@ export default class Cartographer { canvasHeight - (this.tileHeight() / 2); } - move(event) { + move (event) { + if (!has(event, 'height')) event.height = event.target.offsetHeight; + if (!has(event, 'width')) event.width = event.target.offsetWidth; + const newX = this.originX + event.deltaX; const newY = this.originY + event.deltaY; @@ -88,8 +91,8 @@ export default class Cartographer { } _checkMovePositiveTiles(event) { - const canvasWidth = event.target.offsetWidth; - const canvasHeight = event.target.offsetHeight; + const canvasWidth = event.width; + const canvasHeight = event.height; const colWidth = this.horizontalDistance(); const rowHeight = this.verticalDistance(); @@ -120,7 +123,7 @@ export default class Cartographer { const rowHeight = this.verticalDistance(); if (this.width) { - const canvasWidth = event.target.offsetWidth; + const canvasWidth = event.width; const halfBoardWidth = (this.width * colWidth + this.horizontalOverhang()) / 2; this.originX = this.originX > halfBoardWidth ? halfBoardWidth : @@ -129,7 +132,7 @@ export default class Cartographer { } if (this.height) { - const canvasHeight = event.target.offsetHeight; + const canvasHeight = event.height; const halfBoardHeight = (this.height * rowHeight + this.verticalOverhang()) / 2; this.originY = this.originY > halfBoardHeight ? halfBoardHeight : @@ -153,10 +156,8 @@ export default class Cartographer { this.move({ deltaX: (((event.offsetX - this.originX) / scaleOrig) * (scaleOrig - scaleTemp)), deltaY: (((event.offsetY - this.originY) / scaleOrig) * (scaleOrig - scaleTemp)), - target: { - offsetWidth: event.target.offsetWidth, - offsetHeight: event.target.offsetHeight, - }, + width: event.target.offsetWidth, + height: event.target.offsetHeight, }); } } diff --git a/src/tessellate.js b/src/tessellate.js index 3b98202..7327b24 100644 --- a/src/tessellate.js +++ b/src/tessellate.js @@ -253,10 +253,8 @@ export class Tessellate { const moveForScale = { deltaX: (((centerX - originX) / scaleOrig) * (scaleOrig - scaleNew)), deltaY: (((centerY - originY) / scaleOrig) * (scaleOrig - scaleNew)), - target: { - offsetWidth: event.width, - offsetHeight: event.height, - }, + height: event.height, + width: event.width, }; this.move(moveForScale);