Move fallback to default color to a location where it's accessible (fixes #137)

This commit is contained in:
Manuel Vögele
2021-12-28 16:16:16 +01:00
parent a16f97f9e7
commit 1c8ce20a45
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ export function getColorForDistanceAndToken(distance, token, ranges=null) {
ranges = getRangesFromSpeedProvider(token); ranges = getRangesFromSpeedProvider(token);
} }
if (ranges.length === 0) if (ranges.length === 0)
return this.color; return null;
const currentRange = ranges.reduce((minRange, currentRange) => { const currentRange = ranges.reduce((minRange, currentRange) => {
if (distance <= currentRange.range && currentRange.range < minRange.range) if (distance <= currentRange.range && currentRange.range < minRange.range)
return currentRange; return currentRange;
+1 -1
View File
@@ -169,6 +169,6 @@ export class DragRulerRuler extends Ruler {
distance = Math.round(distance * 100) / 100; distance = Math.round(distance * 100) / 100;
if (!this.dragRulerRanges) if (!this.dragRulerRanges)
this.dragRulerRanges = getRangesFromSpeedProvider(this.draggedEntity); this.dragRulerRanges = getRangesFromSpeedProvider(this.draggedEntity);
return getColorForDistanceAndToken(distance, this.draggedEntity, this.dragRulerRanges); return getColorForDistanceAndToken(distance, this.draggedEntity, this.dragRulerRanges) ?? this.color;
} }
} }