fix resizing
This commit is contained in:
@@ -66,6 +66,9 @@ export default class Cartographer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 newX = this.originX + event.deltaX;
|
||||||
const newY = this.originY + event.deltaY;
|
const newY = this.originY + event.deltaY;
|
||||||
|
|
||||||
@@ -88,8 +91,8 @@ export default class Cartographer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_checkMovePositiveTiles(event) {
|
_checkMovePositiveTiles(event) {
|
||||||
const canvasWidth = event.target.offsetWidth;
|
const canvasWidth = event.width;
|
||||||
const canvasHeight = event.target.offsetHeight;
|
const canvasHeight = event.height;
|
||||||
|
|
||||||
const colWidth = this.horizontalDistance();
|
const colWidth = this.horizontalDistance();
|
||||||
const rowHeight = this.verticalDistance();
|
const rowHeight = this.verticalDistance();
|
||||||
@@ -120,7 +123,7 @@ export default class Cartographer {
|
|||||||
const rowHeight = this.verticalDistance();
|
const rowHeight = this.verticalDistance();
|
||||||
|
|
||||||
if (this.width) {
|
if (this.width) {
|
||||||
const canvasWidth = event.target.offsetWidth;
|
const canvasWidth = event.width;
|
||||||
const halfBoardWidth = (this.width * colWidth + this.horizontalOverhang()) / 2;
|
const halfBoardWidth = (this.width * colWidth + this.horizontalOverhang()) / 2;
|
||||||
|
|
||||||
this.originX = this.originX > halfBoardWidth ? halfBoardWidth :
|
this.originX = this.originX > halfBoardWidth ? halfBoardWidth :
|
||||||
@@ -129,7 +132,7 @@ export default class Cartographer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.height) {
|
if (this.height) {
|
||||||
const canvasHeight = event.target.offsetHeight;
|
const canvasHeight = event.height;
|
||||||
const halfBoardHeight = (this.height * rowHeight + this.verticalOverhang()) / 2;
|
const halfBoardHeight = (this.height * rowHeight + this.verticalOverhang()) / 2;
|
||||||
|
|
||||||
this.originY = this.originY > halfBoardHeight ? halfBoardHeight :
|
this.originY = this.originY > halfBoardHeight ? halfBoardHeight :
|
||||||
@@ -153,10 +156,8 @@ export default class Cartographer {
|
|||||||
this.move({
|
this.move({
|
||||||
deltaX: (((event.offsetX - this.originX) / scaleOrig) * (scaleOrig - scaleTemp)),
|
deltaX: (((event.offsetX - this.originX) / scaleOrig) * (scaleOrig - scaleTemp)),
|
||||||
deltaY: (((event.offsetY - this.originY) / scaleOrig) * (scaleOrig - scaleTemp)),
|
deltaY: (((event.offsetY - this.originY) / scaleOrig) * (scaleOrig - scaleTemp)),
|
||||||
target: {
|
width: event.target.offsetWidth,
|
||||||
offsetWidth: event.target.offsetWidth,
|
height: event.target.offsetHeight,
|
||||||
offsetHeight: event.target.offsetHeight,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,10 +253,8 @@ export class Tessellate {
|
|||||||
const moveForScale = {
|
const moveForScale = {
|
||||||
deltaX: (((centerX - originX) / scaleOrig) * (scaleOrig - scaleNew)),
|
deltaX: (((centerX - originX) / scaleOrig) * (scaleOrig - scaleNew)),
|
||||||
deltaY: (((centerY - originY) / scaleOrig) * (scaleOrig - scaleNew)),
|
deltaY: (((centerY - originY) / scaleOrig) * (scaleOrig - scaleNew)),
|
||||||
target: {
|
height: event.height,
|
||||||
offsetWidth: event.width,
|
width: event.width,
|
||||||
offsetHeight: event.height,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.move(moveForScale);
|
this.move(moveForScale);
|
||||||
|
|||||||
Reference in New Issue
Block a user