diff --git a/packages/solid-prevent-scroll/README.md b/packages/solid-prevent-scroll/README.md index 1cdb40bb..f5935dd8 100644 --- a/packages/solid-prevent-scroll/README.md +++ b/packages/solid-prevent-scroll/README.md @@ -11,7 +11,7 @@ SolidJS utility that prevents scrolling outside of a given DOM element. Works by - Supports nested scroll containers - Works both vertically and horizontally -- Removes the body scrollbar without layout shift +- Removes the document scrollbar without layout shift ## Usage diff --git a/packages/solid-prevent-scroll/src/preventScroll.ts b/packages/solid-prevent-scroll/src/preventScroll.ts index eeb2445c..d410570f 100644 --- a/packages/solid-prevent-scroll/src/preventScroll.ts +++ b/packages/solid-prevent-scroll/src/preventScroll.ts @@ -27,8 +27,8 @@ const isActive = (id: string) => * * @param props.element - Prevent scroll outside of this element. If the element is `null`, scroll will be prevented on the whole page. *Default = `null`* * @param props.enabled - Whether scroll should be prevented. *Default = `true`* - * @param props.hideScrollbar - Whether the scrollbar of the `
` element should be hidden. *Default = `true`* - * @param props.preventScrollbarShift - Whether padding should be added to the `` element to avoid layout shift. *Default = `true`* + * @param props.hideScrollbar - Whether the scrollbar of the document element should be hidden. *Default = `true`* + * @param props.preventScrollbarShift - Whether padding should be added to the document element to avoid layout shift. *Default = `true`* * @param props.preventScrollbarShiftMode - Whether padding or margin should be used to avoid layout shift. *Default = `'padding'`* * @param props.restoreScrollPosition - Whether to restore the `` scroll position with `window.scrollTo` to avoid possible layout shift after disabling the utility. *Default = `true`* * @param props.allowPinchZoom - Whether pinch zoom should be allowed. *Default = `false`* @@ -80,9 +80,9 @@ const createPreventScroll = (props: { ) return - const { body } = document + const { documentElement } = document - const scrollbarWidth = window.innerWidth - body.offsetWidth + const scrollbarWidth = window.innerWidth - documentElement.clientWidth if (access(defaultedProps.preventScrollbarShift)) { const style: Partial