From 46edfa8ae6d09a1d0d3e0fbc1d7c25afca75c3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Fri, 5 Feb 2021 00:54:09 +0100 Subject: [PATCH] Fix a bug where tokens wouldn't be moved to the corect end position on gridless maps --- CHANGELOG.md | 4 ++++ src/foundry_imports.js | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85b77e0..0f58c64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## In development +### Bugfixes +- Fixed a bug where tokens wouldn't be moved to the corect end position on gridless maps + ## v1.1.0 ### New features - The drag ruler will now be colored for other players than the dragging player as well (only if they have at least observer permissions for that token) diff --git a/src/foundry_imports.js b/src/foundry_imports.js index 58402d2..2c8263b 100644 --- a/src/foundry_imports.js +++ b/src/foundry_imports.js @@ -44,10 +44,17 @@ async function animateToken(token, rays, tokenOffset, wasPaused) { // Determine offset relative to the Token top-left. // This is important so we can position the token relative to the ruler origin for non-1x1 tokens. - const origin = canvas.grid.getTopLeft(this.waypoints[0].x + tokenOffset.x, this.waypoints[0].y + tokenOffset.y); - const s2 = canvas.dimensions.size / 2; - const dx = Math.round((token.data.x - origin[0]) / s2) * s2; - const dy = Math.round((token.data.y - origin[1]) / s2) * s2; + origin = canvas.grid.getTopLeft(this.waypoints[0].x + tokenOffset.x, this.waypoints[0].y + tokenOffset.y); + let dx, dy + if (canvas.grid.type === CONST.GRID_TYPES.GRIDLESS) { + dx = token.data.x - origin[0] + dy = token.data.y - origin[1] + } + else { + const s2 = canvas.dimensions.size / 2; + dx = Math.round((token.data.x - origin[0]) / s2) * s2; + dy = Math.round((token.data.y - origin[1]) / s2) * s2; + } token._noAnimate = true; for (let r of offsetRays) {