mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-29 14:06:32 +01:00
Only update hash when the camera is no longer moving
to reduce the history-spam as much as possible while still retaining the url-feature
This commit is contained in:
parent
67f1e03f00
commit
d9a2f98481
@ -248,7 +248,7 @@ export default class BlueMap {
|
||||
this.hiresTileManager.setPosition(this.controls.targetPosition);
|
||||
}
|
||||
|
||||
this.locationHash =
|
||||
let newHash =
|
||||
'#' + this.map
|
||||
+ ':' + Math.floor(this.controls.targetPosition.x)
|
||||
+ ':' + Math.floor(this.controls.targetPosition.z)
|
||||
@ -256,10 +256,18 @@ export default class BlueMap {
|
||||
+ ':' + Math.round(this.controls.targetDistance * 100) / 100
|
||||
+ ':' + Math.ceil(this.controls.targetAngle * 100) / 100
|
||||
+ ':' + Math.floor(this.controls.terrainHeight);
|
||||
|
||||
// only update hash when changed
|
||||
if (window.location.hash !== this.locationHash) {
|
||||
if (window.location.hash !== newHash) {
|
||||
|
||||
// but wait until it has finished changing (update when camera is no longer moving, to reduce the number of updates and history spam)
|
||||
if (this.locationHash === newHash) {
|
||||
history.replaceState(undefined, undefined, this.locationHash);
|
||||
}
|
||||
|
||||
this.locationHash = newHash;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
render = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user