[skip ci] support previous/next buttons in the browser to switch between tabs
This commit is contained in:
1 parent
8ff4847977
commit
4c94db2c03
5 files changed
+38
-23
No files matched your search
@@ -31,6 +31,12 @@
|
||||
} else {
|
||||
setScreenNameInUrl("home");
|
||||
}
|
||||
|
||||
window.addEventListener("hashchange", OnWindowHashChange);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("hashchange", OnWindowHashChange);
|
||||
};
|
||||
});
|
||||
|
||||
function getScreenNameInUrl(): AppState["screen"] | undefined {
|
||||
@@ -47,6 +53,16 @@
|
||||
function setScreenNameInUrl(screen: AppState["screen"]) {
|
||||
window.location.hash = screen;
|
||||
}
|
||||
|
||||
function OnWindowHashChange() {
|
||||
const screen = getScreenNameInUrl();
|
||||
if (screen && screen !== $appStateStore.screen) {
|
||||
appStateStore.update((state) => {
|
||||
state.screen = screen;
|
||||
return state;
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- https://github.com/saadeghi/daisyui/issues/1732#issuecomment-1747818200 -->
|
||||
|
||||
Reference in new issue
Block a user