v0.12.1 - fix $SlideViewer slide animate

This commit is contained in:
defaultkavy 2024-10-25 16:52:25 +08:00
parent 9d1d8fca39
commit 4ecc5cd06b
Signed by: defaultkavy
GPG Key ID: DFBB22C4E69D7826
4 changed files with 8 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');
</script>
<script type="module" crossorigin src="/assets/index-DOm6Phmh.js"></script>
<script type="module" crossorigin src="/assets/index-DUv7nhbW.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Bmz9OSnh.css">
</head>
<body>

View File

@ -2,7 +2,7 @@
"name": "danbooru-viewer",
"module": "index.ts",
"type": "module",
"version": "0.12.0",
"version": "0.12.1",
"scripts": {
"dev": "bun x vite",
"build": "bun x vite build",

View File

@ -94,8 +94,9 @@ export class $SlideViewer extends $Container<HTMLElement, $SlideViewerEventMap>
}, {
duration: 300,
easing: ease ? 'ease' : 'ease-out',
}, () => {
this.__render__();
}, (animation) => {
this.$container.css({left: `-${this.getPositionLeft(currentIndex)}px`})
this.__render__(false);
})
}
@ -124,7 +125,7 @@ export class $SlideViewer extends $Container<HTMLElement, $SlideViewerEventMap>
protected getPositionLeft(index: number) { return index * this.dom.clientWidth }
protected __render__() {
protected __render__(positioning = true) {
let i = 0;
this.slideMap.forEach($slide => {
$slide.hide(true, false);
@ -137,7 +138,7 @@ export class $SlideViewer extends $Container<HTMLElement, $SlideViewerEventMap>
if (currentIndex !== 0) this.slideList.at(currentIndex - 1)?.build().hide(false, false);
if (currentIndex !== this.slideList.length - 1) this.slideList.at(currentIndex + 1)?.build().hide(false, false);
this.$container.children.render();
this.$container.css({left: `-${this.getPositionLeft(currentIndex)}px`})
if (positioning) this.$container.css({left: `-${this.getPositionLeft(currentIndex)}px`})
}
pointerException(resolver: (pointer: $Pointer, e: PointerEvent) => boolean) {