@graphcommerce/framer-scroller 2.1.11 → 2.1.12
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 +13 -0
- package/components/ScrollerButton.tsx +14 -3
- package/hooks/useScrollTo.ts +14 -6
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1477](https://github.com/graphcommerce-org/graphcommerce/pull/1477) [`55c2dcde7`](https://github.com/graphcommerce-org/graphcommerce/commit/55c2dcde7869ee51b84494af653b3edfd43904a4) Thanks [@paales](https://github.com/paales)! - ScrollerButton prev/next button wouldn't render at the right time
|
|
8
|
+
|
|
9
|
+
* [#1477](https://github.com/graphcommerce-org/graphcommerce/pull/1477) [`f167f9963`](https://github.com/graphcommerce-org/graphcommerce/commit/f167f99630966a7de43717937d43669e66132494) Thanks [@paales](https://github.com/paales)! - LayoutOverlay performance improvements
|
|
10
|
+
|
|
11
|
+
* Updated dependencies [[`a9df81310`](https://github.com/graphcommerce-org/graphcommerce/commit/a9df81310c051876dd82fb2819105dece47cc213), [`f167f9963`](https://github.com/graphcommerce-org/graphcommerce/commit/f167f99630966a7de43717937d43669e66132494)]:
|
|
12
|
+
- @graphcommerce/next-ui@4.8.1
|
|
13
|
+
- @graphcommerce/framer-utils@3.1.3
|
|
14
|
+
- @graphcommerce/image@3.1.6
|
|
15
|
+
|
|
3
16
|
## 2.1.11
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -18,14 +18,25 @@ export const ScrollerButton = m(
|
|
|
18
18
|
const scrollTo = useScrollTo()
|
|
19
19
|
const handleClick = () => scrollTo(getSnapPosition(direction))
|
|
20
20
|
|
|
21
|
-
const { xProgress, yProgress, xMax, yMax } = useElementScroll(scrollerRef
|
|
21
|
+
const { xProgress, yProgress, xMax, yMax } = useElementScroll(scrollerRef)
|
|
22
22
|
|
|
23
23
|
const progress = useTransform<number, number>(
|
|
24
24
|
[xProgress, yProgress, xMax, yMax],
|
|
25
25
|
([x, y, xM, yM]) => {
|
|
26
26
|
if (xM === 0 && yM === 0) return 0
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
switch (direction) {
|
|
29
|
+
case 'left':
|
|
30
|
+
return x < 0.1 ? 0 : 1
|
|
31
|
+
case 'right':
|
|
32
|
+
return x > 0.9 ? 0 : 1
|
|
33
|
+
case 'up':
|
|
34
|
+
return y < 0.1 ? 0 : 1
|
|
35
|
+
case 'down':
|
|
36
|
+
return y > 0.9 ? 0 : 1
|
|
37
|
+
default:
|
|
38
|
+
return 0
|
|
39
|
+
}
|
|
29
40
|
},
|
|
30
41
|
)
|
|
31
42
|
const scale = useSpring(progress)
|
package/hooks/useScrollTo.ts
CHANGED
|
@@ -13,7 +13,7 @@ export function useScrollTo() {
|
|
|
13
13
|
const ref = scrollerRef.current
|
|
14
14
|
if (!ref) return
|
|
15
15
|
|
|
16
|
-
// In the future we want to move to browser native scrolling behavior, but since
|
|
16
|
+
// In the future we want to move to browser native scrolling behavior, but since the animation timing isn't configurable we can't use it.
|
|
17
17
|
// if ('scrollBehavior' in document.documentElement.style) {
|
|
18
18
|
// scrollerRef.current.scrollTo({ left: to.x, top: to.y, behavior: 'smooth' })
|
|
19
19
|
// await new Promise((onComplete) => {
|
|
@@ -22,6 +22,9 @@ export function useScrollTo() {
|
|
|
22
22
|
// return
|
|
23
23
|
// }
|
|
24
24
|
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
26
|
+
scroll.scroll.start(() => () => {})
|
|
27
|
+
|
|
25
28
|
const xDone = new Promise<void>((onComplete) => {
|
|
26
29
|
if (ref.scrollLeft !== to.x) {
|
|
27
30
|
disableSnap()
|
|
@@ -32,10 +35,11 @@ export function useScrollTo() {
|
|
|
32
35
|
velocity: scroll.x.getVelocity(),
|
|
33
36
|
onUpdate: (v) => {
|
|
34
37
|
ref.scrollLeft = v
|
|
38
|
+
scroll.scroll.set({ ...scroll.scroll.get(), x: v })
|
|
35
39
|
},
|
|
36
40
|
onComplete,
|
|
37
41
|
onStop: onComplete,
|
|
38
|
-
duration:
|
|
42
|
+
duration: 375,
|
|
39
43
|
}),
|
|
40
44
|
)
|
|
41
45
|
} else onComplete()
|
|
@@ -49,22 +53,26 @@ export function useScrollTo() {
|
|
|
49
53
|
from: ref.scrollTop,
|
|
50
54
|
to: to.y,
|
|
51
55
|
velocity: scroll.y.getVelocity(),
|
|
52
|
-
onUpdate: (v) => {
|
|
56
|
+
onUpdate: (v: number) => {
|
|
53
57
|
ref.scrollTop = v
|
|
58
|
+
scroll.scroll.set({ ...scroll.scroll.get(), y: v })
|
|
54
59
|
},
|
|
55
60
|
onComplete,
|
|
56
61
|
onStop: onComplete,
|
|
57
|
-
duration:
|
|
62
|
+
duration: 375,
|
|
58
63
|
}),
|
|
59
64
|
)
|
|
60
|
-
} else
|
|
65
|
+
} else {
|
|
66
|
+
onComplete()
|
|
67
|
+
}
|
|
61
68
|
})
|
|
62
69
|
|
|
63
70
|
await xDone
|
|
64
71
|
await yDone
|
|
72
|
+
scroll.scroll.stop()
|
|
65
73
|
enableSnap()
|
|
66
74
|
},
|
|
67
|
-
[disableSnap, enableSnap, register, scroll
|
|
75
|
+
[disableSnap, enableSnap, register, scroll, scrollerRef],
|
|
68
76
|
)
|
|
69
77
|
|
|
70
78
|
return scrollTo
|
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": "2.1.
|
|
5
|
+
"version": "2.1.12",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "tsc -W"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@graphcommerce/framer-utils": "3.1.
|
|
19
|
-
"@graphcommerce/image": "3.1.
|
|
20
|
-
"@graphcommerce/next-ui": "4.8.
|
|
18
|
+
"@graphcommerce/framer-utils": "3.1.3",
|
|
19
|
+
"@graphcommerce/image": "3.1.6",
|
|
20
|
+
"@graphcommerce/next-ui": "4.8.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@graphcommerce/eslint-config-pwa": "^4.1.7",
|