Skip to content

Commit f4f24bb

Browse files
committed
Only update location on hash change fixes #9
1 parent 9d4b586 commit f4f24bb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

BlueMapCore/src/main/webroot/js/libs/BlueMap.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,17 @@ export default class BlueMap {
207207
}
208208

209209
this.locationHash =
210-
'#' + this.map
211-
+ ':' + Math.floor(this.controls.targetPosition.x)
212-
+ ':' + Math.floor(this.controls.targetPosition.z)
213-
+ ':' + Math.round(this.controls.targetDirection * 100) / 100
214-
+ ':' + Math.round(this.controls.targetDistance * 100) / 100
215-
+ ':' + Math.ceil(this.controls.targetAngle * 100) / 100
216-
+ ':' + Math.floor(this.controls.targetPosition.y);
217-
history.replaceState(undefined, undefined, this.locationHash);
210+
'#' + this.map
211+
+ ':' + Math.floor(this.controls.targetPosition.x)
212+
+ ':' + Math.floor(this.controls.targetPosition.z)
213+
+ ':' + Math.round(this.controls.targetDirection * 100) / 100
214+
+ ':' + Math.round(this.controls.targetDistance * 100) / 100
215+
+ ':' + Math.ceil(this.controls.targetAngle * 100) / 100
216+
+ ':' + Math.floor(this.controls.targetPosition.y);
217+
// only update hash when changed
218+
if (window.location.hash !== this.locationHash) {
219+
history.replaceState(undefined, undefined, this.locationHash);
220+
}
218221
};
219222

220223
render = () => {

0 commit comments

Comments
 (0)