@graphcommerce/framer-scroller 6.0.2-canary.8 → 6.1.0
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 +58 -0
- package/hooks/useScrollTo.ts +28 -6
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 6.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b8bd4abcd`](https://github.com/graphcommerce-org/graphcommerce/commit/b8bd4abcdfb9fc96ec5a724b449df713b99af23b) - Do not change the behavior of the useScrollTo, only warn about possible problems. ([@paales](https://github.com/paales))
|
|
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
|
+
|
|
15
|
+
- [#1901](https://github.com/graphcommerce-org/graphcommerce/pull/1901) [`54aadf39f`](https://github.com/graphcommerce-org/graphcommerce/commit/54aadf39fa9cf2d84c7feab8bc07703e3d02741d) - Make sure the stop function is stopping both x and y animations to prevent rare occasions where a direction isn’t cancelled ([@paales](https://github.com/paales))
|
|
16
|
+
|
|
17
|
+
## 6.0.2-canary.22
|
|
18
|
+
|
|
19
|
+
## 6.0.2-canary.21
|
|
20
|
+
|
|
21
|
+
## 6.0.2-canary.20
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#1901](https://github.com/graphcommerce-org/graphcommerce/pull/1901) [`54aadf39f`](https://github.com/graphcommerce-org/graphcommerce/commit/54aadf39fa9cf2d84c7feab8bc07703e3d02741d) - Make sure the stop function is stopping both x and y animations to prevent rare occasions where a direction isn’t cancelled ([@paales](https://github.com/paales))
|
|
26
|
+
|
|
27
|
+
## 6.0.2-canary.19
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [`b8bd4abcd`](https://github.com/graphcommerce-org/graphcommerce/commit/b8bd4abcdfb9fc96ec5a724b449df713b99af23b) - Do not change the behavior of the useScrollTo, only warn about possible problems. ([@paales](https://github.com/paales))
|
|
32
|
+
|
|
33
|
+
## 6.0.2-canary.18
|
|
34
|
+
|
|
35
|
+
## 6.0.2-canary.17
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [#1895](https://github.com/graphcommerce-org/graphcommerce/pull/1895) [`e6dbddc01`](https://github.com/graphcommerce-org/graphcommerce/commit/e6dbddc019358f13886288ae065da2def0c1b335) - `useScrollTo` improvements for easier debugging:
|
|
40
|
+
|
|
41
|
+
- When a `scrollTo` animation is requesed while an animation is is progress it will throw an error
|
|
42
|
+
- When a `scrollTo` animation is retriggered more than 5 times, it will throw an error
|
|
43
|
+
- When a `scrollTo` detects the overlay is resized after the animation it will show a warning. ([@paales](https://github.com/paales))
|
|
44
|
+
|
|
45
|
+
## 6.0.2-canary.16
|
|
46
|
+
|
|
47
|
+
## 6.0.2-canary.15
|
|
48
|
+
|
|
49
|
+
## 6.0.2-canary.14
|
|
50
|
+
|
|
51
|
+
## 6.0.2-canary.13
|
|
52
|
+
|
|
53
|
+
## 6.0.2-canary.12
|
|
54
|
+
|
|
55
|
+
## 6.0.2-canary.11
|
|
56
|
+
|
|
57
|
+
## 6.0.2-canary.10
|
|
58
|
+
|
|
59
|
+
## 6.0.2-canary.9
|
|
60
|
+
|
|
3
61
|
## 6.0.2-canary.8
|
|
4
62
|
|
|
5
63
|
## 6.0.2-canary.7
|
package/hooks/useScrollTo.ts
CHANGED
|
@@ -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,10 +24,32 @@ export function useScrollTo() {
|
|
|
24
24
|
to = incoming
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
if (process.env.NODE_ENV === 'development' && scroll.animating.get() && retrigger === 0) {
|
|
28
|
+
console.warn(
|
|
29
|
+
`scrollTo triggered while another animation is in progress. This cancels the current animation and creates a new one.`,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (process.env.NODE_ENV === 'development' && retrigger > 5) {
|
|
34
|
+
console.error(
|
|
35
|
+
`scrollTo triggered more than 5 times, is the element resizing constantly? Bailing out.`,
|
|
36
|
+
)
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (process.env.NODE_ENV === 'development' && retrigger > 0) {
|
|
41
|
+
console.warn(
|
|
42
|
+
`scrollTo re-animating to because the final location changed during animation.`,
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const stop: { stop: () => void }[] = []
|
|
47
|
+
|
|
27
48
|
const xDone = new Promise<void>((onComplete) => {
|
|
28
49
|
if (ref.scrollLeft !== to.x) {
|
|
29
50
|
disableSnap()
|
|
30
|
-
|
|
51
|
+
|
|
52
|
+
stop.push(
|
|
31
53
|
animate({
|
|
32
54
|
from: ref.scrollLeft,
|
|
33
55
|
to: to.x,
|
|
@@ -47,7 +69,7 @@ export function useScrollTo() {
|
|
|
47
69
|
const yDone = new Promise<void>((onComplete) => {
|
|
48
70
|
if (ref.scrollTop !== to.y) {
|
|
49
71
|
disableSnap()
|
|
50
|
-
|
|
72
|
+
stop.push(
|
|
51
73
|
animate({
|
|
52
74
|
from: ref.scrollTop,
|
|
53
75
|
to: to.y,
|
|
@@ -67,13 +89,13 @@ export function useScrollTo() {
|
|
|
67
89
|
}
|
|
68
90
|
})
|
|
69
91
|
|
|
70
|
-
|
|
71
|
-
await yDone
|
|
92
|
+
register({ stop: () => stop.forEach((s) => s.stop()) })
|
|
93
|
+
await Promise.all([xDone, yDone])
|
|
72
94
|
|
|
73
95
|
if (Array.isArray(incoming)) {
|
|
74
96
|
const checkPositions = getScrollSnapPositions()
|
|
75
97
|
if (checkPositions.x[incoming[0]] !== to.x || checkPositions.y[incoming[1]] !== to.y)
|
|
76
|
-
await scrollTo(incoming)
|
|
98
|
+
await scrollTo(incoming, retrigger + 1)
|
|
77
99
|
}
|
|
78
100
|
enableSnap()
|
|
79
101
|
},
|
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
|
|
5
|
+
"version": "6.1.0",
|
|
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
|
|
20
|
-
"@graphcommerce/image": "6.0
|
|
19
|
+
"@graphcommerce/framer-utils": "6.1.0",
|
|
20
|
+
"@graphcommerce/image": "6.1.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@graphcommerce/eslint-config-pwa": "6.0
|
|
24
|
-
"@graphcommerce/prettier-config-pwa": "6.0
|
|
25
|
-
"@graphcommerce/typescript-config-pwa": "6.0
|
|
23
|
+
"@graphcommerce/eslint-config-pwa": "6.1.0",
|
|
24
|
+
"@graphcommerce/prettier-config-pwa": "6.1.0",
|
|
25
|
+
"@graphcommerce/typescript-config-pwa": "6.1.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@mui/material": "^5.10.16",
|