summaryrefslogtreecommitdiff
path: root/packages/client/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-07-05 22:25:27 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-07-05 22:25:27 +0900
commit62f8af489150784c6803d4faf2e24b65bc3f86ea (patch)
tree38791ab1535b9518e2cbb373d4ed7962e8e2c416 /packages/client/src
parentfeat(client): メニューからページをリロードできるように (diff)
downloadmisskey-62f8af489150784c6803d4faf2e24b65bc3f86ea.tar.gz
misskey-62f8af489150784c6803d4faf2e24b65bc3f86ea.tar.bz2
misskey-62f8af489150784c6803d4faf2e24b65bc3f86ea.zip
enhance(client): improve usability
Diffstat (limited to 'packages/client/src')
-rw-r--r--packages/client/src/nirax.ts7
-rw-r--r--packages/client/src/router.ts4
2 files changed, 10 insertions, 1 deletions
diff --git a/packages/client/src/nirax.ts b/packages/client/src/nirax.ts
index 19c4464ea8..cd29ae87a5 100644
--- a/packages/client/src/nirax.ts
+++ b/packages/client/src/nirax.ts
@@ -61,6 +61,7 @@ export class Router extends EventEmitter<{
props: Map<string, string> | null;
key: string;
}) => void;
+ same: () => void;
}> {
private routes: RouteDef[];
private currentPath: string;
@@ -210,11 +211,15 @@ export class Router extends EventEmitter<{
}
public push(path: string) {
+ const beforePath = this.currentPath;
+ if (path === beforePath) {
+ this.emit('same');
+ return;
+ }
if (this.navHook) {
const cancel = this.navHook(path);
if (cancel) return;
}
- const beforePath = this.currentPath;
this.navigate(path, null);
this.emit('push', {
beforePath,
diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts
index b3baad188e..2ff41e9723 100644
--- a/packages/client/src/router.ts
+++ b/packages/client/src/router.ts
@@ -258,6 +258,10 @@ mainRouter.addListener('push', ctx => {
}
});
+mainRouter.addListener('same', () => {
+ window.scroll({ top: 0, behavior: 'smooth' });
+});
+
window.addEventListener('popstate', (event) => {
mainRouter.change(location.pathname + location.search + location.hash, event.state?.key);
const scrollPos = scrollPosStore.get(event.state?.key) ?? 0;