diff --git a/assets/ts/container.ts b/assets/ts/container.ts index 8dd3c99..63fd864 100644 --- a/assets/ts/container.ts +++ b/assets/ts/container.ts @@ -4,8 +4,8 @@ export let container: HTMLDivElement export function initContainer(): void { container = document.getElementsByClassName('container').item(0) as HTMLDivElement - scrollable.addWatcher(() => { - if (scrollable.get()) { + scrollable.addWatcher((o) => { + if (o) { container.classList.remove('disableScroll') } else { container.classList.add('disableScroll') diff --git a/assets/ts/desktop/customCursor.ts b/assets/ts/desktop/customCursor.ts index 5476a35..6b1bf4d 100644 --- a/assets/ts/desktop/customCursor.ts +++ b/assets/ts/desktop/customCursor.ts @@ -38,8 +38,8 @@ export function initCustomCursor(): void { // bind mousemove event to window window.addEventListener('mousemove', onMouse, { passive: true }) // add active callback - active.addWatcher(() => { - if (active.get()) { + active.addWatcher((o) => { + if (o) { cursor.classList.add('active') } else { cursor.classList.remove('active') diff --git a/assets/ts/desktop/stage.ts b/assets/ts/desktop/stage.ts index 04a0eb3..eb73eb7 100644 --- a/assets/ts/desktop/stage.ts +++ b/assets/ts/desktop/stage.ts @@ -211,13 +211,13 @@ export function initStage(ijs: ImageJSON[]): void { }) window.addEventListener('mousemove', onMouse, { passive: true }) // watchers - isOpen.addWatcher(() => { - active.set(isOpen.get() && !isAnimating.get()) + isOpen.addWatcher((o) => { + active.set(o && !isAnimating.get()) }) - isAnimating.addWatcher(() => { - active.set(isOpen.get() && !isAnimating.get()) + isAnimating.addWatcher((o) => { + active.set(isOpen.get() && !o) }) - cordHist.addWatcher(() => { + cordHist.addWatcher((_) => { setPositions() }) // preload diff --git a/assets/ts/mobile/gallery.ts b/assets/ts/mobile/gallery.ts index a042d45..9b36174 100644 --- a/assets/ts/mobile/gallery.ts +++ b/assets/ts/mobile/gallery.ts @@ -93,8 +93,8 @@ export function initGallery(ijs: ImageJSON[]): void { lastIndex = s.index }) // mounted watcher - mounted.addWatcher(() => { - if (!mounted.get()) return + mounted.addWatcher((o) => { + if (!o) return scrollable.set(true) swiper = new Swiper(swiperNode, { spaceBetween: 20 }) swiper.on('slideChange', ({ realIndex }) => { diff --git a/assets/ts/utils.ts b/assets/ts/utils.ts index 751a3c0..9cdfef3 100644 --- a/assets/ts/utils.ts +++ b/assets/ts/utils.ts @@ -42,7 +42,7 @@ export function onVisible( export class Watchable { constructor(private obj: T) {} - private readonly watchers: Array<() => void> = [] + private readonly watchers: Array<(arg0: T) => void> = [] get(): T { return this.obj @@ -51,11 +51,11 @@ export class Watchable { set(e: T): void { this.obj = e this.watchers.forEach((watcher) => { - watcher() + watcher(this.obj) }) } - addWatcher(watcher: () => void): void { + addWatcher(watcher: (arg0: T) => void): void { this.watchers.push(watcher) } }