From b4ac65e478f32741acfd2a75e679534edf40091b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 25 Mar 2021 01:54:53 +0100 Subject: [PATCH] Fix snapping for tokens that are smaller than 1x1 (fixes #48) --- CHANGELOG.md | 6 ++++++ src/util.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8245b95..301476b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.4.4 +### Bugfixes +- Fix snapping for tokens that are smaller than 1x1 + + + ## 1.4.3 ### System compatibility - Drag Ruler's Generic SpeedProvider is now aware of good default values for the Savage Worlds Adventure Edition game system diff --git a/src/util.js b/src/util.js index a17f2b9..bacb6d0 100644 --- a/src/util.js +++ b/src/util.js @@ -16,7 +16,7 @@ export function getSnapPointForToken(x, y, token) { return new PIXI.Point(...canvas.grid.getCenter(x, y)) } } - if (canvas.grid.isHex || token.data.width % 2 === 1) { + if (canvas.grid.isHex || Math.round(token.data.width) % 2 === 1 || token.data.width < 1) { return new PIXI.Point(...canvas.grid.getCenter(x, y)) } const [snappedX, snappedY] = canvas.grid.getCenter(x - canvas.grid.w / 2, y - canvas.grid.h / 2)