fix: menu button not push hash state.
optimize: $Search and $Drawer open and close method will determine hash first.
This commit is contained in:
defaultkavy 2024-10-13 08:42:57 +08:00
parent acf412de6b
commit a94bcd6f81
Signed by: defaultkavy
GPG Key ID: DFBB22C4E69D7826
5 changed files with 10 additions and 7 deletions

File diff suppressed because one or more lines are too long

2
dist/index.html vendored
View File

@ -16,7 +16,7 @@
gtag('config', 'G-59HBGP98WR'); gtag('config', 'G-59HBGP98WR');
</script> </script>
<script type="module" crossorigin src="/assets/index-Dg3fAkPK.js"></script> <script type="module" crossorigin src="/assets/index-BjMPWQj7.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CPDn8S3u.css"> <link rel="stylesheet" crossorigin href="/assets/index-CPDn8S3u.css">
</head> </head>
<body> <body>

View File

@ -2,7 +2,7 @@
"name": "danbooru-viewer", "name": "danbooru-viewer",
"module": "index.ts", "module": "index.ts",
"type": "module", "type": "module",
"version": "0.6.1", "version": "0.6.2",
"devDependencies": { "devDependencies": {
"@types/bun": "latest", "@types/bun": "latest",
"vite": "^5.4.8", "vite": "^5.4.8",

View File

@ -49,7 +49,10 @@ export class $Drawer extends $Container {
]) ])
} }
open() { open() { if (location.hash !== '#drawer') $.open(location.href + '#drawer'); return this; }
close() { if (location.hash === '#drawer') $.back(); return this; }
private activate() {
this.hide(false); this.hide(false);
this.$container.animate({ this.$container.animate({
transform: [`translateX(100%)`, `translateX(0%)`] transform: [`translateX(100%)`, `translateX(0%)`]
@ -67,7 +70,7 @@ export class $Drawer extends $Container {
}) })
} }
close() { private inactivate() {
this.$container.animate({ this.$container.animate({
transform: [`translateX(0%)`, `translateX(100%)`] transform: [`translateX(0%)`, `translateX(100%)`]
}, { }, {

View File

@ -41,8 +41,8 @@ export class $Searchbar extends $Container {
]) ])
} }
open() { $.open(location.href + '#search'); return this; } open() { if (location.hash !== '#search') $.open(location.href + '#search'); return this; }
close() { $.back(); return this; } close() { if (location.hash === '#search') $.back(); return this; }
activate() { activate() {
this.hide(false); this.hide(false);