Fix back button on mobile devices
This commit is contained in:
parent
2bb50561fe
commit
f8b68aee7a
2 changed files with 5 additions and 2 deletions
|
@ -18,9 +18,7 @@ export default class SelectedFeatureHandler {
|
||||||
this._featureSource = featureSource;
|
this._featureSource = featureSource;
|
||||||
const self = this;
|
const self = this;
|
||||||
hash.addCallback(h => {
|
hash.addCallback(h => {
|
||||||
console.log("Hash is now ", h)
|
|
||||||
if (h === undefined || h === "") {
|
if (h === undefined || h === "") {
|
||||||
console.error("Deselecting feature...")
|
|
||||||
selectedFeature.setData(undefined);
|
selectedFeature.setData(undefined);
|
||||||
}else{
|
}else{
|
||||||
self.selectFeature();
|
self.selectFeature();
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import {UIEventSource} from "../UIEventSource";
|
import {UIEventSource} from "../UIEventSource";
|
||||||
import {Utils} from "../../Utils";
|
import {Utils} from "../../Utils";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper around the hash to create an UIEventSource from it
|
||||||
|
*/
|
||||||
export default class Hash {
|
export default class Hash {
|
||||||
|
|
||||||
public static hash: UIEventSource<string> = Hash.Get();
|
public static hash: UIEventSource<string> = Hash.Get();
|
||||||
|
@ -33,12 +36,14 @@ export default class Hash {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
history.pushState({}, "")
|
||||||
window.location.hash = "#" + h;
|
window.location.hash = "#" + h;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
window.onhashchange = () => {
|
window.onhashchange = () => {
|
||||||
let newValue = window.location.hash.substr(1);
|
let newValue = window.location.hash.substr(1);
|
||||||
|
console.log("The hash is now:", newValue)
|
||||||
if (newValue === "") {
|
if (newValue === "") {
|
||||||
newValue = undefined;
|
newValue = undefined;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue