Cache the output of SpeedProvider.getRanges during a drag to increase speed provider performance

This commit is contained in:
Manuel Vögele
2021-04-29 12:40:17 +02:00
parent 4671e6de51
commit 1acc012d65
3 changed files with 8 additions and 2 deletions
+3 -1
View File
@@ -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) => {