Start measuring immediately when the token is being dragged
This commit is contained in:
@@ -74,3 +74,23 @@ function calculateTokenOffset(tokenA, tokenB) {
|
||||
function applyOffsetToRay(ray, offset) {
|
||||
return new Ray({x: ray.A.x + offset.x, y: ray.A.y + offset.y}, {x: ray.B.x + offset.x, y: ray.B.y + offset.y})
|
||||
}
|
||||
|
||||
// This is a modified version of Ruler._onMouseMove from foundry 0.7.9
|
||||
export function onMouseMove(event) {
|
||||
if (this._state === Ruler.STATES.MOVING) return;
|
||||
|
||||
// Extract event data
|
||||
const mt = event._measureTime || 0;
|
||||
const { destination, originalEvent } = event.data;
|
||||
|
||||
// Hide any existing Token HUD
|
||||
canvas.hud.token.clear();
|
||||
delete event.data.hudState;
|
||||
|
||||
// Draw measurement updates
|
||||
if (Date.now() - mt > 50) {
|
||||
this.measure(destination, { gridSpaces: !originalEvent.shiftKey });
|
||||
event._measureTime = Date.now();
|
||||
this._state = Ruler.STATES.MEASURING;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
"use strict"
|
||||
|
||||
import {availableSpeedProviders, currentSpeedProvider, registerModule, registerSystem, setCurrentSpeedProvider} from "./api.js"
|
||||
import {moveTokens} from "./foundry_imports.js"
|
||||
import {moveTokens, onMouseMove} from "./foundry_imports.js"
|
||||
import {registerSettings, settingsKey} from "./settings.js"
|
||||
|
||||
Hooks.once("init", () => {
|
||||
@@ -98,7 +98,7 @@ function onTokenLeftDragStart(event) {
|
||||
|
||||
function onTokenLeftDragMove(event) {
|
||||
if (canvas.controls.ruler.isDragRuler)
|
||||
canvas.controls.ruler._onMouseMove(event)
|
||||
onMouseMove.call(canvas.controls.ruler, event)
|
||||
}
|
||||
|
||||
function onTokenDragLeftDrop(event) {
|
||||
|
||||
Reference in New Issue
Block a user