Start measuring immediately when the token is being dragged
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
## In development
|
## In development
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- Fixed a bug where tokens wouldn't be moved to the corect end position on gridless maps
|
- Fixed a bug where tokens wouldn't be moved to the corect end position on gridless maps
|
||||||
|
- Ruler now appears immediately when the token is being dragged
|
||||||
|
|
||||||
## v1.1.0
|
## v1.1.0
|
||||||
### New features
|
### New features
|
||||||
|
|||||||
@@ -74,3 +74,23 @@ function calculateTokenOffset(tokenA, tokenB) {
|
|||||||
function applyOffsetToRay(ray, offset) {
|
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})
|
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"
|
"use strict"
|
||||||
|
|
||||||
import {availableSpeedProviders, currentSpeedProvider, registerModule, registerSystem, setCurrentSpeedProvider} from "./api.js"
|
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"
|
import {registerSettings, settingsKey} from "./settings.js"
|
||||||
|
|
||||||
Hooks.once("init", () => {
|
Hooks.once("init", () => {
|
||||||
@@ -98,7 +98,7 @@ function onTokenLeftDragStart(event) {
|
|||||||
|
|
||||||
function onTokenLeftDragMove(event) {
|
function onTokenLeftDragMove(event) {
|
||||||
if (canvas.controls.ruler.isDragRuler)
|
if (canvas.controls.ruler.isDragRuler)
|
||||||
canvas.controls.ruler._onMouseMove(event)
|
onMouseMove.call(canvas.controls.ruler, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTokenDragLeftDrop(event) {
|
function onTokenDragLeftDrop(event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user