@graphcommerce/framer-scroller 7.1.0-canary.13 → 7.1.0-canary.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 7.1.0-canary.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2045](https://github.com/graphcommerce-org/graphcommerce/pull/2045) [`1ac1e0989`](https://github.com/graphcommerce-org/graphcommerce/commit/1ac1e09897daadd646200cb3ddc2aa75a51e182e) - Make sure the product image gallery traps focus and scrollbar doesn't disappear suddenly ([@JoshuaS98](https://github.com/JoshuaS98))
8
+
3
9
  ## 7.1.0-canary.13
4
10
 
5
11
  ## 7.1.0-canary.12
@@ -0,0 +1,23 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import { unstable_getScrollbarSize as getScrollbarSize } from '@mui/utils'
3
+ import { useEffect, useId } from 'react'
4
+
5
+ function usePreventScroll(shouldPrevent: boolean) {
6
+ const id = useId()
7
+
8
+ useEffect(() => {
9
+ if (shouldPrevent) {
10
+ const scrollbarSize = getScrollbarSize(document)
11
+
12
+ document.body.style.overflow = 'hidden'
13
+ document.body.style.paddingRight = `${scrollbarSize}px`
14
+ }
15
+
16
+ return () => {
17
+ document.body.style.overflow = ''
18
+ document.body.style.paddingRight = ''
19
+ }
20
+ }, [id, shouldPrevent])
21
+ }
22
+
23
+ export const unstable_usePreventScroll = usePreventScroll
package/index.ts CHANGED
@@ -12,3 +12,4 @@ export * from './hooks/useScrollerContext'
12
12
  // export * from './hooks/useScroller'
13
13
  export * from './hooks/useScrollTo'
14
14
  export * from './hooks/useWatchItems'
15
+ export * from './hooks/usePreventScroll'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/framer-scroller",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "7.1.0-canary.13",
5
+ "version": "7.1.0-canary.14",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"
@@ -16,13 +16,13 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "popmotion": "11.0.5",
19
- "@graphcommerce/framer-utils": "7.1.0-canary.13",
20
- "@graphcommerce/image": "7.1.0-canary.13"
19
+ "@graphcommerce/framer-utils": "7.1.0-canary.14",
20
+ "@graphcommerce/image": "7.1.0-canary.14"
21
21
  },
22
22
  "devDependencies": {
23
- "@graphcommerce/eslint-config-pwa": "7.1.0-canary.13",
24
- "@graphcommerce/prettier-config-pwa": "7.1.0-canary.13",
25
- "@graphcommerce/typescript-config-pwa": "7.1.0-canary.13"
23
+ "@graphcommerce/eslint-config-pwa": "7.1.0-canary.14",
24
+ "@graphcommerce/prettier-config-pwa": "7.1.0-canary.14",
25
+ "@graphcommerce/typescript-config-pwa": "7.1.0-canary.14"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@mui/material": "^5.10.16",