Skip to content

Commit

Permalink
The body-scroll-lock package is no longer maintained, trying this one…
Browse files Browse the repository at this point in the history
  • Loading branch information
multivac61 committed Apr 13, 2023
1 parent c501cbf commit 8fd8562
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
"@sveltejs/adapter-static": "^2.0.1",
"@sveltejs/kit": "^1.15.2",
"@tailwindcss/forms": "^0.5.3",
"@types/body-scroll-lock": "^3.1.0",
"tua-body-scroll-lock": "^1.2.1",
"@types/cookie": "^0.5.1",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"autoprefixer": "^10.4.7",
"body-scroll-lock": "4.0.0-beta.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-svelte3": "^4.0.0",
Expand Down
21 changes: 7 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 3 additions & 15 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { onMount } from 'svelte'
import { createDialog } from 'svelte-headlessui'
import Transition from 'svelte-transition'
import { enableBodyScroll, disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock'
import { lock, unlock } from 'tua-body-scroll-lock'
export let data
Expand Down Expand Up @@ -79,21 +79,9 @@
$: if (browser && scrollTarget) {
if ($movie_dialog.expanded) {
disableBodyScroll(scrollTarget, {
reserveScrollBarGap: true,
allowTouchMove: (el: HTMLElement) => {
while (el && el !== document.body as HTMLElement) {
if (el.getAttribute('body-scroll-lock-ignore') !== null) {
return true
}
el = el.parentElement!
}
return false
}
})
lock(scrollTarget)
} else {
enableBodyScroll(scrollTarget)
unlock(scrollTarget)
}
}
Expand Down

0 comments on commit 8fd8562

Please sign in to comment.