@graphcommerce/framer-scroller 6.0.2-canary.16 → 6.0.2-canary.18

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,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.0.2-canary.18
4
+
5
+ ## 6.0.2-canary.17
6
+
7
+ ### Patch Changes
8
+
9
+ - [#1895](https://github.com/graphcommerce-org/graphcommerce/pull/1895) [`e6dbddc01`](https://github.com/graphcommerce-org/graphcommerce/commit/e6dbddc019358f13886288ae065da2def0c1b335) - `useScrollTo` improvements for easier debugging:
10
+
11
+ - When a `scrollTo` animation is requesed while an animation is is progress it will throw an error
12
+ - When a `scrollTo` animation is retriggered more than 5 times, it will throw an error
13
+ - When a `scrollTo` detects the overlay is resized after the animation it will show a warning. ([@paales](https://github.com/paales))
14
+
3
15
  ## 6.0.2-canary.16
4
16
 
5
17
  ## 6.0.2-canary.15
@@ -11,7 +11,7 @@ export function useScrollTo() {
11
11
  const duration = (useContext(MotionConfigContext).transition as Tween | undefined)?.duration ?? 0
12
12
 
13
13
  const scrollTo = useCallback(
14
- async (incoming: Point | [number, number]) => {
14
+ async (incoming: Point | [number, number], retrigger = 0) => {
15
15
  const ref = scrollerRef.current
16
16
  if (!ref) return
17
17
 
@@ -24,6 +24,24 @@ export function useScrollTo() {
24
24
  to = incoming
25
25
  }
26
26
 
27
+ if (process.env.NODE_ENV === 'development' && scroll.animating.get() && retrigger === 0) {
28
+ throw Error(
29
+ `scrollTo triggered while another animation is in progress. Maybe wrap in 'if(!scroll.animating.get())'?`,
30
+ )
31
+ }
32
+
33
+ if (process.env.NODE_ENV === 'development' && retrigger > 5) {
34
+ throw Error(
35
+ `scrollTo triggered more than 5 times, is the element resizing constantly? Bailing out.`,
36
+ )
37
+ }
38
+
39
+ if (process.env.NODE_ENV === 'development' && retrigger > 0) {
40
+ console.warn(
41
+ `scrollTo detect a resize while animating, this can cause the animation to be inaccurate.`,
42
+ )
43
+ }
44
+
27
45
  const xDone = new Promise<void>((onComplete) => {
28
46
  if (ref.scrollLeft !== to.x) {
29
47
  disableSnap()
@@ -73,7 +91,7 @@ export function useScrollTo() {
73
91
  if (Array.isArray(incoming)) {
74
92
  const checkPositions = getScrollSnapPositions()
75
93
  if (checkPositions.x[incoming[0]] !== to.x || checkPositions.y[incoming[1]] !== to.y)
76
- await scrollTo(incoming)
94
+ await scrollTo(incoming, retrigger++)
77
95
  }
78
96
  enableSnap()
79
97
  },
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": "6.0.2-canary.16",
5
+ "version": "6.0.2-canary.18",
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": "6.0.2-canary.16",
20
- "@graphcommerce/image": "6.0.2-canary.16"
19
+ "@graphcommerce/framer-utils": "6.0.2-canary.18",
20
+ "@graphcommerce/image": "6.0.2-canary.18"
21
21
  },
22
22
  "devDependencies": {
23
- "@graphcommerce/eslint-config-pwa": "6.0.2-canary.16",
24
- "@graphcommerce/prettier-config-pwa": "6.0.2-canary.16",
25
- "@graphcommerce/typescript-config-pwa": "6.0.2-canary.16"
23
+ "@graphcommerce/eslint-config-pwa": "6.0.2-canary.18",
24
+ "@graphcommerce/prettier-config-pwa": "6.0.2-canary.18",
25
+ "@graphcommerce/typescript-config-pwa": "6.0.2-canary.18"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@mui/material": "^5.10.16",