diff --git a/CHANGELOG.md b/CHANGELOG.md index 05c51ac..a86758e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## In development -### Bugfixes +### Performance - Greatly increased the performance when playing on huge maps and when moving many tokens at once. +- Huge performance improvements for speed providers. (Technical details: `getRanges` is now being called way less frequently) + +### Bugfixes - When starting to drag a new token while the previous one is still moving the ruler won't dissappear anymore when the previous token arrives at it's destination. diff --git a/src/main.js b/src/main.js index 7fcf401..45e149d 100644 --- a/src/main.js +++ b/src/main.js @@ -185,7 +185,9 @@ export function getColorForDistance(startDistance, subDistance=0) { return this.color } const distance = startDistance + subDistance - const ranges = getRangesFromSpeedProvider(this.draggedToken) + if (!this.dragRulerRanges) + this.dragRulerRanges = getRangesFromSpeedProvider(this.draggedToken) + const ranges = this.dragRulerRanges; if (ranges.length === 0) return this.color const currentRange = ranges.reduce((minRange, currentRange) => { diff --git a/src/ruler.js b/src/ruler.js index 6a33362..b7d0b77 100644 --- a/src/ruler.js +++ b/src/ruler.js @@ -14,6 +14,7 @@ export class DragRulerRuler extends Ruler { super.clear(); this.previousWaypoints = []; this.previousLabels.removeChildren().forEach(c => c.destroy()); + this.dragRulerRanges = undefined; } async moveToken(event) {