Two way scroll binding
This commit is contained in:
10
src/utlis/scroll.ts
Normal file
10
src/utlis/scroll.ts
Normal 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();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user