Fix snapping for tokens that are smaller than 1x1 (fixes #48)

This commit is contained in:
Manuel Vögele
2021-03-25 01:54:53 +01:00
parent 0de01379e9
commit b4ac65e478
2 changed files with 7 additions and 1 deletions
+6
View File
@@ -1,3 +1,9 @@
## 1.4.4
### Bugfixes
- Fix snapping for tokens that are smaller than 1x1
## 1.4.3 ## 1.4.3
### System compatibility ### System compatibility
- Drag Ruler's Generic SpeedProvider is now aware of good default values for the Savage Worlds Adventure Edition game system - Drag Ruler's Generic SpeedProvider is now aware of good default values for the Savage Worlds Adventure Edition game system
+1 -1
View File
@@ -16,7 +16,7 @@ export function getSnapPointForToken(x, y, token) {
return new PIXI.Point(...canvas.grid.getCenter(x, y)) 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)) 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) const [snappedX, snappedY] = canvas.grid.getCenter(x - canvas.grid.w / 2, y - canvas.grid.h / 2)