Two way scroll binding

This commit is contained in:
2022-05-20 02:19:23 +03:00
parent 158d0efd40
commit 49ae4b0dec
7 changed files with 26 additions and 9 deletions

10
src/utlis/scroll.ts Normal file
View File

@@ -0,0 +1,10 @@
import { createEffect } from "solid-js";
export const scrollHereWhenSelected = (element: HTMLElement, store, chapter) => {
return createEffect((prev) => {
if (prev !== store.visibleChapter() && store.visibleChapter() === chapter) {
element.scrollIntoView({behavior: "smooth"})
}
return store.visibleChapter();
});
}