@graphcommerce/framer-scroller 1.2.12 → 2.0.2
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 +147 -147
- package/components/MotionImageAspect.tsx +53 -59
- package/components/Scroller.tsx +11 -4
- package/components/ScrollerButton.tsx +19 -33
- package/components/ScrollerDots.tsx +43 -37
- package/components/ScrollerPageCounter.tsx +9 -18
- package/hooks/useScroller.ts +170 -126
- package/hooks/useVelocitySnapTo.ts +2 -2
- package/index.ts +1 -1
- package/package.json +17 -20
- package/utils/scrollSnapTypeDirection.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,271 +1,271 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [1.2.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.25...@graphcommerce/framer-scroller@1.2.0) (2022-01-03)
|
|
3
|
+
## 2.0.2
|
|
7
4
|
|
|
5
|
+
### Patch Changes
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
|
|
8
|
+
[`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2)
|
|
9
|
+
Thanks [@paales](https://github.com/paales)! - We've moved lots of internal packages from
|
|
10
|
+
`dependencies` to `peerDependencies`. The result of this is that there will be significantly less
|
|
11
|
+
duplicate packages in the node_modules folders.
|
|
10
12
|
|
|
11
|
-
*
|
|
13
|
+
* [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
|
|
14
|
+
[`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)
|
|
15
|
+
Thanks [@paales](https://github.com/paales)! - Upgraded to
|
|
16
|
+
[NextJS 12.1](https://nextjs.org/blog/next-12-1)! This is just for compatibility, but we'll be
|
|
17
|
+
implementing
|
|
18
|
+
[On-demand Incremental Static Regeneration](https://nextjs.org/blog/next-12-1#on-demand-incremental-static-regeneration-beta)
|
|
19
|
+
soon.
|
|
12
20
|
|
|
21
|
+
This will greatly reduce the requirement to rebuid stuff and we'll add a management UI on the
|
|
22
|
+
frontend to be able to revalidate pages manually.
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
* Updated dependencies
|
|
25
|
+
[[`381e4c86a`](https://github.com/ho-nl/m2-pwa/commit/381e4c86a8321ce96e1fa5c7d3c0a0c0ff3e02c7),
|
|
26
|
+
[`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2),
|
|
27
|
+
[`e7c8e2756`](https://github.com/ho-nl/m2-pwa/commit/e7c8e2756d637cbcd2e793d62ef5721d35d9fa7b),
|
|
28
|
+
[`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)]:
|
|
29
|
+
- @graphcommerce/next-ui@4.1.1
|
|
30
|
+
- @graphcommerce/framer-utils@3.0.2
|
|
31
|
+
- @graphcommerce/image@3.0.2
|
|
15
32
|
|
|
16
|
-
|
|
33
|
+
## 2.0.1
|
|
17
34
|
|
|
35
|
+
### Patch Changes
|
|
18
36
|
|
|
37
|
+
- [`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)
|
|
38
|
+
Thanks [@paales](https://github.com/paales)! - Added homepage and repository package.json files,
|
|
39
|
+
so that the packages link to back to the website and repository
|
|
40
|
+
- Updated dependencies
|
|
41
|
+
[[`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)]:
|
|
42
|
+
- @graphcommerce/framer-utils@3.0.1
|
|
43
|
+
- @graphcommerce/image@3.0.1
|
|
44
|
+
- @graphcommerce/next-ui@4.0.1
|
|
19
45
|
|
|
46
|
+
## 2.0.0
|
|
20
47
|
|
|
48
|
+
### Major Changes
|
|
21
49
|
|
|
22
|
-
|
|
50
|
+
- [#1258](https://github.com/ho-nl/m2-pwa/pull/1258)
|
|
51
|
+
[`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)
|
|
52
|
+
Thanks [@paales](https://github.com/paales)! - Upgraded to Material UI 5
|
|
23
53
|
|
|
54
|
+
### Patch Changes
|
|
24
55
|
|
|
25
|
-
|
|
56
|
+
- Updated dependencies
|
|
57
|
+
[[`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)]:
|
|
58
|
+
- @graphcommerce/framer-utils@3.0.0
|
|
59
|
+
- @graphcommerce/image@3.0.0
|
|
60
|
+
- @graphcommerce/next-ui@4.0.0
|
|
26
61
|
|
|
27
|
-
|
|
62
|
+
All notable changes to this project will be documented in this file. See
|
|
63
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
28
64
|
|
|
65
|
+
# [1.2.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.25...@graphcommerce/framer-scroller@1.2.0) (2022-01-03)
|
|
29
66
|
|
|
67
|
+
### Bug Fixes
|
|
30
68
|
|
|
69
|
+
- make sure the useVelocitySnapTo resolves completely
|
|
70
|
+
([9d13fcb](https://github.com/ho-nl/m2-pwa/commit/9d13fcbf63ef8c0a964b9bd81accb6259a693c5c))
|
|
31
71
|
|
|
72
|
+
### Features
|
|
32
73
|
|
|
33
|
-
|
|
74
|
+
- **framer-next-pages:** reduce rerenders when navigating to a new page
|
|
75
|
+
([5cf3301](https://github.com/ho-nl/m2-pwa/commit/5cf330130bb3527057da015e3c4a6fa295d7262e))
|
|
34
76
|
|
|
77
|
+
## [1.1.24](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.23...@graphcommerce/framer-scroller@1.1.24) (2021-12-23)
|
|
35
78
|
|
|
36
79
|
### Bug Fixes
|
|
37
80
|
|
|
38
|
-
|
|
39
|
-
|
|
81
|
+
- **framer-next-pages:** closing is janky, caused by setting pointer-events to none, trying without
|
|
82
|
+
resetting the pointerevents
|
|
83
|
+
([9247fa3](https://github.com/ho-nl/m2-pwa/commit/9247fa312926416802abd68ea04b1e6b52531f2c))
|
|
40
84
|
|
|
85
|
+
## [1.1.22](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.21...@graphcommerce/framer-scroller@1.1.22) (2021-12-22)
|
|
41
86
|
|
|
87
|
+
### Bug Fixes
|
|
42
88
|
|
|
89
|
+
- **framer-scroller:** make sure the first gallery dot is selected initially
|
|
90
|
+
([a2ed37b](https://github.com/ho-nl/m2-pwa/commit/a2ed37bd2c17eef46c0ee4cf8219a141b2e054b4))
|
|
43
91
|
|
|
44
92
|
## [1.1.21](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.20...@graphcommerce/framer-scroller@1.1.21) (2021-12-22)
|
|
45
93
|
|
|
46
|
-
|
|
47
94
|
### Bug Fixes
|
|
48
95
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
96
|
+
- **framer-scroller:** height of the gallery item isn't high enough
|
|
97
|
+
([0e84ba3](https://github.com/ho-nl/m2-pwa/commit/0e84ba3ecb8928870fdc0459a1c6c30fde372d91))
|
|
98
|
+
- **framer-scroller:** make sure the actual image will scale instead of the container
|
|
99
|
+
([8d55630](https://github.com/ho-nl/m2-pwa/commit/8d55630a93cff91ac37e426bbe9f1b25b001556c))
|
|
100
|
+
- **framer-scroller:** would throw ssr warning
|
|
101
|
+
([a3db078](https://github.com/ho-nl/m2-pwa/commit/a3db0781d2433809c0bd4cb6ba37af79b611f3c4))
|
|
56
102
|
|
|
57
103
|
## [1.1.20](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.19...@graphcommerce/framer-scroller@1.1.20) (2021-12-22)
|
|
58
104
|
|
|
59
|
-
|
|
60
105
|
### Bug Fixes
|
|
61
106
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
107
|
+
- **framer-scroller:** gallery didn't align images in the center
|
|
108
|
+
([0cf6066](https://github.com/ho-nl/m2-pwa/commit/0cf60669b2547d2c421eb07c1ba23d7718df74aa))
|
|
109
|
+
- **framer-scroller:** offaxis scroll was allowed on safari
|
|
110
|
+
([4ece409](https://github.com/ho-nl/m2-pwa/commit/4ece409fabad7e686d491cc6bc1682c4507f2d3b))
|
|
68
111
|
|
|
69
112
|
## [1.1.17](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.16...@graphcommerce/framer-scroller@1.1.17) (2021-12-21)
|
|
70
113
|
|
|
71
|
-
|
|
72
114
|
### Bug Fixes
|
|
73
115
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
116
|
+
- **framer-scroller:** apply will change only when animating
|
|
117
|
+
([77fee92](https://github.com/ho-nl/m2-pwa/commit/77fee92c0eb70691b699e1f6ba378ec16c534975))
|
|
79
118
|
|
|
80
119
|
## [1.1.14](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.13...@graphcommerce/framer-scroller@1.1.14) (2021-12-20)
|
|
81
120
|
|
|
82
|
-
|
|
83
121
|
### Bug Fixes
|
|
84
122
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
123
|
+
- **framer-scroller:** remove jank from scroller when opening
|
|
124
|
+
([c618bf2](https://github.com/ho-nl/m2-pwa/commit/c618bf290bd580fe5eb45663c44843dd751e00ed))
|
|
90
125
|
|
|
91
126
|
## [1.1.10](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.9...@graphcommerce/framer-scroller@1.1.10) (2021-12-17)
|
|
92
127
|
|
|
93
|
-
|
|
94
128
|
### Bug Fixes
|
|
95
129
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
130
|
+
- **framer-scroller:** make sure we're not throwing only warning when there are no children
|
|
131
|
+
([001c7d9](https://github.com/ho-nl/m2-pwa/commit/001c7d9a00e447d44134c00bd77505e52cf0f9d4))
|
|
101
132
|
|
|
102
133
|
## [1.1.8](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.7...@graphcommerce/framer-scroller@1.1.8) (2021-12-15)
|
|
103
134
|
|
|
104
|
-
|
|
105
135
|
### Bug Fixes
|
|
106
136
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
137
|
+
- scroller should not snap to off-axis while dragging and direction isn't set to both
|
|
138
|
+
([9118bfc](https://github.com/ho-nl/m2-pwa/commit/9118bfcb1eb9ade5f144167e47e0c26724ce832f))
|
|
112
139
|
|
|
113
140
|
## [1.1.5](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.4...@graphcommerce/framer-scroller@1.1.5) (2021-12-06)
|
|
114
141
|
|
|
115
|
-
|
|
116
142
|
### Bug Fixes
|
|
117
143
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
144
|
+
- Accessibility, SEO
|
|
145
|
+
([a258837](https://github.com/ho-nl/m2-pwa/commit/a258837476d94d20d33e13a4c4f950fff57f7dca))
|
|
123
146
|
|
|
124
147
|
## [1.1.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.1.1...@graphcommerce/framer-scroller@1.1.2) (2021-12-03)
|
|
125
148
|
|
|
126
|
-
|
|
127
149
|
### Bug Fixes
|
|
128
150
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
- height of scroller isn't correct
|
|
152
|
+
([8d847ad](https://github.com/ho-nl/m2-pwa/commit/8d847ad210cfe00bf88386912d97233402e16b81))
|
|
134
153
|
|
|
135
154
|
# [1.1.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.0.4...@graphcommerce/framer-scroller@1.1.0) (2021-12-03)
|
|
136
155
|
|
|
137
|
-
|
|
138
156
|
### Bug Fixes
|
|
139
157
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
158
|
+
- **framer-scroller:** do not scroll in the direction that is not being scrolled when dragging and
|
|
159
|
+
thus delaying the reset to snap
|
|
160
|
+
([3198eed](https://github.com/ho-nl/m2-pwa/commit/3198eed7977039f712784ee6c17031d7efb20c25))
|
|
161
|
+
- **framer-scroller:** recursively find snapPoints for deeply nested children
|
|
162
|
+
([2203f00](https://github.com/ho-nl/m2-pwa/commit/2203f00a97bb4e4b381acad1d86b177105874d1f))
|
|
163
|
+
- **framer-scroller:** set the scrollTop when switching snap
|
|
164
|
+
([8bd35a2](https://github.com/ho-nl/m2-pwa/commit/8bd35a2ebf5d10b44d04048c6360c7ac770221cf))
|
|
165
|
+
- make sure the overlay becomes visible, even if the overlay is scrolled
|
|
166
|
+
([1738c98](https://github.com/ho-nl/m2-pwa/commit/1738c982ea84ec2b93daa824c4b8c86ab2a3f5ed))
|
|
167
|
+
- make sure the overlays are rendered correctly on mobile
|
|
168
|
+
([48f7050](https://github.com/ho-nl/m2-pwa/commit/48f705060e99b997f5b1db03ccc49f1051a1ed8f))
|
|
169
|
+
- make the headerHeight properly configurable
|
|
170
|
+
([c39c942](https://github.com/ho-nl/m2-pwa/commit/c39c942a62a9bb9687ea553be28e37fb49a6b065))
|
|
147
171
|
|
|
148
172
|
### Features
|
|
149
173
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
174
|
+
- **framer-scroller-sheet:** created package replacing the framer-sheet package
|
|
175
|
+
([f9f2e91](https://github.com/ho-nl/m2-pwa/commit/f9f2e9101191f5cb5c4514ceb9534ddeb2476763))
|
|
176
|
+
- **framer-scroller:** find the direction of the scroller and set proper values
|
|
177
|
+
([631e24c](https://github.com/ho-nl/m2-pwa/commit/631e24c5c7ff67b49f83390789e8dadcb07eca04))
|
|
178
|
+
- **framer-scroller:** get the scrollSnapAlign from the element instead of the body
|
|
179
|
+
([ec8c24e](https://github.com/ho-nl/m2-pwa/commit/ec8c24e6d457a3ed1c055b27d7b94be5ed4b6f2c))
|
|
180
|
+
- **framer-scroller:** provide promise with scrollTo
|
|
181
|
+
([cbe59d9](https://github.com/ho-nl/m2-pwa/commit/cbe59d9e753cc2ab76b2de048139e0319f08d035))
|
|
182
|
+
- **framer-scroller:** split the grid functionality from the scroller
|
|
183
|
+
([81307ea](https://github.com/ho-nl/m2-pwa/commit/81307ea2652bf31a1f94e8db72af4ee161bdca2e))
|
|
159
184
|
|
|
160
185
|
## [1.0.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@1.0.1...@graphcommerce/framer-scroller@1.0.2) (2021-11-03)
|
|
161
186
|
|
|
162
|
-
|
|
163
187
|
### Bug Fixes
|
|
164
188
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
189
|
+
- various accessibility improvements
|
|
190
|
+
([47481a9](https://github.com/ho-nl/m2-pwa/commit/47481a9a882ba87968de6dd797557b0b275d75fb))
|
|
170
191
|
|
|
171
192
|
## [0.4.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@0.4.1...@graphcommerce/framer-scroller@0.4.2) (2021-10-29)
|
|
172
193
|
|
|
173
|
-
|
|
174
194
|
### Bug Fixes
|
|
175
195
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
196
|
+
- spacing of title on category landing on mobile
|
|
197
|
+
([8ed3550](https://github.com/ho-nl/m2-pwa/commit/8ed35502fd231d1d6a8e0a282f8961335d9dead3))
|
|
181
198
|
|
|
182
199
|
# [0.4.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@0.3.3...@graphcommerce/framer-scroller@0.4.0) (2021-10-27)
|
|
183
200
|
|
|
184
|
-
|
|
185
201
|
### Features
|
|
186
202
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
203
|
+
- **nextjs:** upgraded to nextjs 12
|
|
204
|
+
([9331bc8](https://github.com/ho-nl/m2-pwa/commit/9331bc801f6419522115cc47d291d49d608d5a90))
|
|
192
205
|
|
|
193
206
|
# [0.3.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@0.2.11...@graphcommerce/framer-scroller@0.3.0) (2021-10-19)
|
|
194
207
|
|
|
195
|
-
|
|
196
208
|
### Features
|
|
197
209
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
210
|
+
- **framer-scroller:** better defaults so the Scroller doesn't look broken when providing no props
|
|
211
|
+
([b177ce9](https://github.com/ho-nl/m2-pwa/commit/b177ce9570abb9ccfd4eb5cc34e43d157bb4e81a))
|
|
203
212
|
|
|
204
213
|
## [0.2.9](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@0.2.8...@graphcommerce/framer-scroller@0.2.9) (2021-10-11)
|
|
205
214
|
|
|
206
|
-
|
|
207
215
|
### Bug Fixes
|
|
208
216
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
217
|
+
- **framer-scroller:** dots should have a background
|
|
218
|
+
([8f2e1a1](https://github.com/ho-nl/m2-pwa/commit/8f2e1a1ffc9de3369938fe2f9e9f25f592739d8d))
|
|
214
219
|
|
|
215
220
|
## [0.2.8](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@0.2.7...@graphcommerce/framer-scroller@0.2.8) (2021-10-09)
|
|
216
221
|
|
|
217
|
-
|
|
218
222
|
### Bug Fixes
|
|
219
223
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
- **framer-scroller:** pan snap does not work on mobile
|
|
225
|
+
([660f242](https://github.com/ho-nl/m2-pwa/commit/660f242a38558669fa896a74e14cafdd85069d57))
|
|
225
226
|
|
|
226
227
|
## [0.2.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@0.2.0...@graphcommerce/framer-scroller@0.2.2) (2021-09-27)
|
|
227
228
|
|
|
228
|
-
|
|
229
229
|
### Bug Fixes
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
- ignore example directories when publishing
|
|
232
|
+
([620cbb2](https://github.com/ho-nl/m2-pwa/commit/620cbb2d8e68b727b8593e2e45702c4d12276d92))
|
|
233
|
+
- versions
|
|
234
|
+
([b8b306c](https://github.com/ho-nl/m2-pwa/commit/b8b306c8f3a13415e441d0593c638ae2a3731cd6))
|
|
237
235
|
|
|
238
236
|
## [0.2.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-scroller@0.2.0...@graphcommerce/framer-scroller@0.2.1) (2021-09-27)
|
|
239
237
|
|
|
240
238
|
**Note:** Version bump only for package @graphcommerce/framer-scroller
|
|
241
239
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
240
|
# 0.2.0 (2021-09-27)
|
|
247
241
|
|
|
248
|
-
|
|
249
242
|
### Bug Fixes
|
|
250
243
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
244
|
+
- **framer-scroller:** center the prev/next buttons on the gallery
|
|
245
|
+
([234dc37](https://github.com/ho-nl/m2-pwa/commit/234dc37fc46f723410e9a844bbcb33cfe5d8a588))
|
|
246
|
+
- **framer-scroller:** check if the ref exists instead of throwing an exception
|
|
247
|
+
([9cdfa0d](https://github.com/ho-nl/m2-pwa/commit/9cdfa0dd749c59159ce8f6f53dbabbcdddab049c))
|
|
248
|
+
- **framer-slider:** prev/next buttons don't always show up correctly
|
|
249
|
+
([ba2510e](https://github.com/ho-nl/m2-pwa/commit/ba2510ea659344a2d71957eed396f4e5ce536a8c))
|
|
250
|
+
- make sure we can actually observe items
|
|
251
|
+
([4767b2a](https://github.com/ho-nl/m2-pwa/commit/4767b2a1bb23fc6d2e445c10c96da0a666212c55))
|
|
256
252
|
|
|
257
253
|
### Features
|
|
258
254
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
255
|
+
- **framer-scroller:** created an MotionImageAspect component to properly center and handle scorller
|
|
256
|
+
resizes
|
|
257
|
+
([2eb117e](https://github.com/ho-nl/m2-pwa/commit/2eb117e6c135ea8e009c91f854e9f9ef8e7375c5))
|
|
258
|
+
- **framer-scroller:** implemented the scroller on all pages
|
|
259
|
+
([73fb518](https://github.com/ho-nl/m2-pwa/commit/73fb518eff74edb2b3212e892b3d8cc2b088011b))
|
|
260
|
+
- **framer-scroller:** option to hide scrollbar
|
|
261
|
+
([f6a8329](https://github.com/ho-nl/m2-pwa/commit/f6a8329d2f761956a9d7bdc5243de336aa2e5ad4))
|
|
262
|
+
- **framer-scroller:** package to implement scroll-snap handling with JS
|
|
263
|
+
([b3a279f](https://github.com/ho-nl/m2-pwa/commit/b3a279f8b4acb2b9de99004efe0459c534786bdd))
|
|
264
|
+
- **framer-scroller:** pagination dots
|
|
265
|
+
([6a5557d](https://github.com/ho-nl/m2-pwa/commit/6a5557d10d08661662eb476c5fe2296b558c1cb5))
|
|
266
|
+
- renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of
|
|
267
|
+
[@reachdigital](https://github.com/reachdigital)
|
|
268
|
+
([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
|
|
269
269
|
|
|
270
270
|
# Change Log
|
|
271
271
|
|
|
@@ -292,8 +292,8 @@ All notable changes to this project will be documented in this file. See
|
|
|
292
292
|
|
|
293
293
|
### Features
|
|
294
294
|
|
|
295
|
-
- **framer-scroller:** created an MotionImageAspect component to properly center
|
|
296
|
-
|
|
295
|
+
- **framer-scroller:** created an MotionImageAspect component to properly center and handle scorller
|
|
296
|
+
resizes
|
|
297
297
|
([2eb117e](https://github.com/ho-nl/m2-pwa/commit/2eb117e6c135ea8e009c91f854e9f9ef8e7375c5))
|
|
298
298
|
- **framer-scroller:** implemented the scroller on all pages
|
|
299
299
|
([73fb518](https://github.com/ho-nl/m2-pwa/commit/73fb518eff74edb2b3212e892b3d8cc2b088011b))
|
|
@@ -1,47 +1,7 @@
|
|
|
1
1
|
import { Image, ImageProps } from '@graphcommerce/image'
|
|
2
|
-
import {
|
|
3
|
-
import clsx from 'clsx'
|
|
2
|
+
import { Box } from '@mui/material'
|
|
4
3
|
import { m } from 'framer-motion'
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const useStyles = makeStyles(
|
|
8
|
-
{
|
|
9
|
-
root: {
|
|
10
|
-
position: 'relative',
|
|
11
|
-
},
|
|
12
|
-
picture: {
|
|
13
|
-
display: 'block',
|
|
14
|
-
'@supports (aspect-ratio: 1 / 1)': {
|
|
15
|
-
maxWidth: '99.6%',
|
|
16
|
-
maxHeight: '100%',
|
|
17
|
-
width: 'auto',
|
|
18
|
-
height: 'auto',
|
|
19
|
-
|
|
20
|
-
position: 'absolute',
|
|
21
|
-
top: '50%',
|
|
22
|
-
left: '50%',
|
|
23
|
-
transform: 'translate(-50%, -50%)',
|
|
24
|
-
|
|
25
|
-
'&:after': {
|
|
26
|
-
display: 'block',
|
|
27
|
-
content: '""',
|
|
28
|
-
minWidth: '100vw',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
'@supports not (aspect-ratio: 1 / 1)': {
|
|
32
|
-
width: '100% !important',
|
|
33
|
-
height: '100% !important',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
image: {
|
|
37
|
-
display: 'block',
|
|
38
|
-
'@supports not (aspect-ratio: 1 / 1)': {
|
|
39
|
-
objectFit: 'contain',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{ name: 'MotionImageAspect' },
|
|
44
|
-
)
|
|
4
|
+
import { forwardRef } from 'react'
|
|
45
5
|
|
|
46
6
|
export type MotionImageAspectProps = Omit<ImageProps, 'layout' | 'unoptimized'>
|
|
47
7
|
|
|
@@ -53,23 +13,57 @@ export type MotionImageAspectProps = Omit<ImageProps, 'layout' | 'unoptimized'>
|
|
|
53
13
|
* problem when the layout is animated. Should be fixed in Safari 15
|
|
54
14
|
*/
|
|
55
15
|
const MotionImageAspect = m(
|
|
56
|
-
forwardRef<HTMLImageElement, MotionImageAspectProps>((props, ref) =>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
16
|
+
forwardRef<HTMLImageElement, MotionImageAspectProps>((props, ref) => (
|
|
17
|
+
<Box
|
|
18
|
+
className='MotionImageAspect'
|
|
19
|
+
sx={{
|
|
20
|
+
position: 'relative',
|
|
21
|
+
|
|
22
|
+
'& > picture': {
|
|
23
|
+
display: 'block',
|
|
24
|
+
'@supports (aspect-ratio: 1 / 1)': {
|
|
25
|
+
maxWidth: '99.6%',
|
|
26
|
+
maxHeight: '100%',
|
|
27
|
+
width: 'auto',
|
|
28
|
+
height: 'auto',
|
|
29
|
+
|
|
30
|
+
position: 'absolute',
|
|
31
|
+
top: '50%',
|
|
32
|
+
left: '50%',
|
|
33
|
+
transform: 'translate(-50%, -50%)',
|
|
34
|
+
|
|
35
|
+
'&:after': {
|
|
36
|
+
display: 'block',
|
|
37
|
+
content: '""',
|
|
38
|
+
minWidth: '100vw',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
'@supports not (aspect-ratio: 1 / 1)': {
|
|
42
|
+
width: '100% !important',
|
|
43
|
+
height: '100% !important',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
'& > img': {
|
|
47
|
+
display: 'block',
|
|
48
|
+
'@supports not (aspect-ratio: 1 / 1)': {
|
|
49
|
+
objectFit: 'contain',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<Image
|
|
55
|
+
{...props}
|
|
56
|
+
layout='fill'
|
|
57
|
+
ref={ref}
|
|
58
|
+
className={props.className}
|
|
59
|
+
pictureProps={{
|
|
60
|
+
...props.pictureProps,
|
|
61
|
+
className: props.pictureProps?.className,
|
|
62
|
+
style: { ...props.style, aspectRatio: `${props.width} / ${props.height}` },
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
</Box>
|
|
66
|
+
)),
|
|
73
67
|
)
|
|
74
68
|
|
|
75
69
|
MotionImageAspect.displayName = 'MotionImageAspect'
|
package/components/Scroller.tsx
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { styled, SxProps, Theme } from '@mui/material'
|
|
1
2
|
import { m } from 'framer-motion'
|
|
2
3
|
import { forwardRef } from 'react'
|
|
3
4
|
import { ScrollableProps, useScroller } from '../hooks/useScroller'
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const ScrollerDiv = styled(m.div)({})
|
|
7
|
+
|
|
8
|
+
const Scroller = forwardRef<HTMLDivElement, ScrollableProps & { sx?: SxProps<Theme> }>(
|
|
9
|
+
(props, forwardedRef) => {
|
|
10
|
+
const { sx = [], ...scrollerProps } = props
|
|
11
|
+
const scroller = useScroller<'div'>({ grid: true, ...scrollerProps }, forwardedRef)
|
|
12
|
+
|
|
13
|
+
return <ScrollerDiv {...scroller} sx={[scroller.sx, ...(Array.isArray(sx) ? sx : [sx])]} />
|
|
14
|
+
},
|
|
15
|
+
)
|
|
9
16
|
Scroller.displayName = 'Scroller'
|
|
10
17
|
|
|
11
18
|
export default Scroller
|
|
@@ -1,58 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fab, FabProps
|
|
3
|
-
import { m,
|
|
1
|
+
import { useElementScroll } from '@graphcommerce/framer-utils'
|
|
2
|
+
import { Fab, FabProps } from '@mui/material'
|
|
3
|
+
import { m, useSpring, useTransform } from 'framer-motion'
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import { useScrollTo } from '../hooks/useScrollTo'
|
|
6
6
|
import { useScrollerContext } from '../hooks/useScrollerContext'
|
|
7
|
-
import { useWatchItems } from '../hooks/useWatchItems'
|
|
8
7
|
import { SnapPositionDirection } from '../types'
|
|
9
8
|
|
|
10
|
-
const useStyles = makeStyles((theme: Theme) => ({
|
|
11
|
-
root: {
|
|
12
|
-
[theme.breakpoints.down('xs')]: {
|
|
13
|
-
display: 'none',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
}))
|
|
17
|
-
|
|
18
9
|
export type ScrollerButtonProps = {
|
|
19
10
|
direction: SnapPositionDirection
|
|
20
|
-
} & FabProps
|
|
21
|
-
UseStyles<typeof useStyles>
|
|
11
|
+
} & FabProps
|
|
22
12
|
|
|
23
13
|
const ScrollerFab = m(
|
|
24
14
|
React.forwardRef<HTMLDivElement, ScrollerButtonProps>((props, ref) => {
|
|
25
|
-
const { direction, ...buttonProps } = props
|
|
26
|
-
const classes = useStyles(buttonProps)
|
|
27
|
-
|
|
28
|
-
const end = direction === 'right' || direction === 'down'
|
|
15
|
+
const { direction, sx = [], ...buttonProps } = props
|
|
29
16
|
|
|
30
|
-
const { getSnapPosition } = useScrollerContext()
|
|
17
|
+
const { getSnapPosition, scrollerRef } = useScrollerContext()
|
|
31
18
|
const scrollTo = useScrollTo()
|
|
32
19
|
const handleClick = () => scrollTo(getSnapPosition(direction))
|
|
33
20
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
useWatchItems((_, itemArr) => {
|
|
37
|
-
const itemVisbility = end
|
|
38
|
-
? itemArr[itemArr.length - 1].visibility.get()
|
|
39
|
-
: itemArr[0].visibility.get()
|
|
21
|
+
const { xProgress, yProgress, xMax, yMax } = useElementScroll(scrollerRef, 1)
|
|
40
22
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
const progress = useTransform<number, number>(
|
|
24
|
+
[xProgress, yProgress, xMax, yMax],
|
|
25
|
+
([x, y, xM, yM]) => {
|
|
26
|
+
if (xM === 0 && yM === 0) return 0
|
|
27
|
+
if (direction === 'right' || direction === 'down') return x * y === 1 ? 0 : 1
|
|
28
|
+
return x * y === 0 ? 0 : 1
|
|
29
|
+
},
|
|
30
|
+
)
|
|
31
|
+
const scale = useSpring(progress)
|
|
47
32
|
|
|
48
33
|
return (
|
|
49
|
-
<m.div ref={ref} style={{ scale, opacity: scale }}>
|
|
34
|
+
<m.div ref={ref} style={{ scale, opacity: scale, willChange: 'scale, opacity', zIndex: 1 }}>
|
|
50
35
|
<Fab
|
|
51
36
|
type='button'
|
|
52
37
|
{...buttonProps}
|
|
53
38
|
onClick={handleClick}
|
|
54
|
-
classes={{ ...classes, ...buttonProps.classes }}
|
|
55
39
|
aria-label={direction}
|
|
40
|
+
size='small'
|
|
41
|
+
sx={[{ display: { xs: 'none', md: 'flex' } }, ...(Array.isArray(sx) ? sx : [sx])]}
|
|
56
42
|
/>
|
|
57
43
|
</m.div>
|
|
58
44
|
)
|
|
@@ -1,50 +1,45 @@
|
|
|
1
1
|
import { useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
|
-
import {
|
|
3
|
-
import { Fab, FabProps,
|
|
4
|
-
import
|
|
5
|
-
import { HTMLMotionProps, m } from 'framer-motion'
|
|
2
|
+
import { extendableComponent } from '@graphcommerce/next-ui/Styles'
|
|
3
|
+
import { Fab, FabProps, styled, SxProps, Theme } from '@mui/material'
|
|
4
|
+
import { m } from 'framer-motion'
|
|
6
5
|
import React from 'react'
|
|
7
6
|
import { useScrollTo } from '../hooks/useScrollTo'
|
|
8
7
|
import { useScrollerContext } from '../hooks/useScrollerContext'
|
|
9
8
|
|
|
10
|
-
const
|
|
11
|
-
(theme: Theme) => ({
|
|
12
|
-
dots: {
|
|
13
|
-
width: 'fit-content',
|
|
14
|
-
display: 'grid',
|
|
15
|
-
gridAutoFlow: 'column',
|
|
16
|
-
padding: `0 6px`,
|
|
17
|
-
borderRadius: '99em',
|
|
18
|
-
},
|
|
19
|
-
dot: {
|
|
20
|
-
boxShadow: 'none',
|
|
21
|
-
background: 'transparent',
|
|
22
|
-
},
|
|
23
|
-
circle: {
|
|
24
|
-
borderRadius: '99em',
|
|
25
|
-
width: 10,
|
|
26
|
-
height: 10,
|
|
27
|
-
background: theme.palette.text.primary,
|
|
28
|
-
},
|
|
29
|
-
}),
|
|
30
|
-
{ name: 'ScrollerDots' },
|
|
31
|
-
)
|
|
9
|
+
const MotionBox = styled(m.div)({})
|
|
32
10
|
|
|
33
11
|
export type DotsProps = {
|
|
34
12
|
fabProps?: Omit<FabProps, 'onClick' | 'children'>
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
sx?: SxProps<Theme>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const componentName = 'ScrollerDots'
|
|
17
|
+
const { classes } = extendableComponent(componentName, ['root', 'dot', 'circle'] as const)
|
|
37
18
|
|
|
38
19
|
const ScrollerDots = m(
|
|
39
20
|
React.forwardRef<HTMLDivElement, DotsProps>((props, ref) => {
|
|
40
|
-
const { fabProps,
|
|
41
|
-
|
|
21
|
+
const { fabProps, sx = [], ...containerProps } = props
|
|
22
|
+
|
|
42
23
|
const { items, getScrollSnapPositions } = useScrollerContext()
|
|
43
24
|
const itemsArr = useMotionValueValue(items, (v) => v)
|
|
44
25
|
const scrollTo = useScrollTo()
|
|
45
26
|
|
|
46
27
|
return (
|
|
47
|
-
<
|
|
28
|
+
<MotionBox
|
|
29
|
+
{...containerProps}
|
|
30
|
+
className={classes.root}
|
|
31
|
+
ref={ref}
|
|
32
|
+
sx={[
|
|
33
|
+
{
|
|
34
|
+
width: 'fit-content',
|
|
35
|
+
display: 'grid',
|
|
36
|
+
gridAutoFlow: 'column',
|
|
37
|
+
padding: `0 6px`,
|
|
38
|
+
borderRadius: '99em',
|
|
39
|
+
},
|
|
40
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
41
|
+
]}
|
|
42
|
+
>
|
|
48
43
|
{itemsArr.map((item, idx) => (
|
|
49
44
|
<Fab
|
|
50
45
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -57,18 +52,29 @@ const ScrollerDots = m(
|
|
|
57
52
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
58
53
|
scrollTo({ x: positions.x[idx] ?? 0, y: positions.y[idx] ?? 0 })
|
|
59
54
|
}}
|
|
60
|
-
className={
|
|
61
|
-
classes={classes}
|
|
55
|
+
className={classes.dot}
|
|
62
56
|
aria-label={`img-${idx}`}
|
|
57
|
+
sx={{
|
|
58
|
+
boxShadow: 'none',
|
|
59
|
+
background: 'transparent',
|
|
60
|
+
}}
|
|
63
61
|
>
|
|
64
|
-
<
|
|
62
|
+
<MotionBox
|
|
63
|
+
className={classes.circle}
|
|
64
|
+
sx={(theme) => ({
|
|
65
|
+
borderRadius: '99em',
|
|
66
|
+
width: 10,
|
|
67
|
+
height: 10,
|
|
68
|
+
background: theme.palette.text.primary,
|
|
69
|
+
})}
|
|
70
|
+
style={{ opacity: item.opacity }}
|
|
71
|
+
/>
|
|
65
72
|
</Fab>
|
|
66
73
|
))}
|
|
67
|
-
</
|
|
74
|
+
</MotionBox>
|
|
68
75
|
)
|
|
69
76
|
}),
|
|
70
77
|
)
|
|
71
|
-
|
|
72
|
-
ScrollerDots.displayName = 'ScrollerDots'
|
|
78
|
+
ScrollerDots.displayName = componentName
|
|
73
79
|
|
|
74
80
|
export default ScrollerDots
|
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import { useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { m, MotionProps } from 'framer-motion'
|
|
2
|
+
import { styled, SxProps, Theme } from '@mui/material'
|
|
3
|
+
import { m } from 'framer-motion'
|
|
5
4
|
import React, { useState } from 'react'
|
|
6
5
|
import { useScrollerContext } from '../hooks/useScrollerContext'
|
|
7
6
|
import { useWatchItems } from '../hooks/useWatchItems'
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
(theme: Theme) => ({
|
|
11
|
-
pageCounter: {
|
|
12
|
-
...theme.typography.h4,
|
|
13
|
-
},
|
|
14
|
-
}),
|
|
15
|
-
{ name: 'SliderPageCounter' },
|
|
16
|
-
)
|
|
8
|
+
const MotionDiv = styled(m.div)({})
|
|
17
9
|
|
|
18
|
-
export type SliderPageCounterProps =
|
|
19
|
-
|
|
10
|
+
export type SliderPageCounterProps = {
|
|
11
|
+
sx?: SxProps<Theme>
|
|
12
|
+
}
|
|
20
13
|
|
|
21
14
|
const ScrollerPageCounter = React.forwardRef<HTMLDivElement, SliderPageCounterProps>(
|
|
22
|
-
(
|
|
23
|
-
const { className, ...divProps } = props
|
|
24
|
-
const classes = useStyles(props)
|
|
15
|
+
({ sx = [] }, ref) => {
|
|
25
16
|
const { items } = useScrollerContext()
|
|
26
17
|
|
|
27
18
|
const [current, setCurrent] = useState(1)
|
|
@@ -37,9 +28,9 @@ const ScrollerPageCounter = React.forwardRef<HTMLDivElement, SliderPageCounterPr
|
|
|
37
28
|
})
|
|
38
29
|
|
|
39
30
|
return (
|
|
40
|
-
<
|
|
31
|
+
<MotionDiv ref={ref} sx={[{ typography: 'h4' }, ...(Array.isArray(sx) ? sx : [sx])]}>
|
|
41
32
|
<span>{String(current).padStart(2, '0')}</span> — {String(count).padStart(2, '0')}
|
|
42
|
-
</
|
|
33
|
+
</MotionDiv>
|
|
43
34
|
)
|
|
44
35
|
},
|
|
45
36
|
)
|
package/hooks/useScroller.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useConstant, useElementScroll, useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { extendableComponent } from '@graphcommerce/next-ui/Styles'
|
|
3
|
+
import { SxProps, Theme } from '@mui/material'
|
|
4
4
|
import {
|
|
5
5
|
HTMLMotionProps,
|
|
6
6
|
motionValue,
|
|
@@ -11,124 +11,29 @@ import {
|
|
|
11
11
|
useTransform,
|
|
12
12
|
} from 'framer-motion'
|
|
13
13
|
import React, { ReactHTML, useState } from 'react'
|
|
14
|
-
import { ScrollSnapProps } from '../types'
|
|
15
14
|
import { isHTMLMousePointerEvent } from '../utils/isHTMLMousePointerEvent'
|
|
16
|
-
import { scrollSnapTypeDirection } from '../utils/scrollSnapTypeDirection'
|
|
15
|
+
import { scrollSnapTypeDirection, SnapTypeDirection } from '../utils/scrollSnapTypeDirection'
|
|
17
16
|
import { useScrollerContext } from './useScrollerContext'
|
|
18
17
|
import { useVelocitySnapTo } from './useVelocitySnapTo'
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
userSelect: 'none',
|
|
25
|
-
userDrag: 'none',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
rootSmSnapDirNone: {
|
|
29
|
-
[theme.breakpoints.down('sm')]: {
|
|
30
|
-
overflow: 'hidden',
|
|
31
|
-
overscrollBehavior: 'auto',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
rootMdSnapDirNone: {
|
|
35
|
-
[theme.breakpoints.up('md')]: {
|
|
36
|
-
overflow: 'hidden',
|
|
37
|
-
overscrollBehavior: 'auto',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
rootSmSnapDirBlock: {
|
|
41
|
-
[theme.breakpoints.down('sm')]: {
|
|
42
|
-
overflowY: 'auto',
|
|
43
|
-
overflowX: 'hidden',
|
|
44
|
-
overscrollBehaviorBlock: 'contain',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
rootMdSnapDirBlock: {
|
|
48
|
-
[theme.breakpoints.up('md')]: {
|
|
49
|
-
overflowY: 'auto',
|
|
50
|
-
overflowX: 'hidden',
|
|
51
|
-
overscrollBehaviorBlock: 'contain',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
rootSmSnapDirInline: {
|
|
55
|
-
[theme.breakpoints.down('sm')]: {
|
|
56
|
-
overflowX: 'auto',
|
|
57
|
-
overflowY: 'hidden',
|
|
58
|
-
overscrollBehaviorInline: 'contain',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
rootMdSnapDirInline: {
|
|
62
|
-
[theme.breakpoints.up('md')]: {
|
|
63
|
-
overflowX: 'auto',
|
|
64
|
-
overflowY: 'hidden',
|
|
65
|
-
overscrollBehaviorInline: 'contain',
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
rootSmSnapDirBoth: {
|
|
69
|
-
[theme.breakpoints.down('sm')]: {
|
|
70
|
-
overflow: 'auto',
|
|
71
|
-
overscrollBehavior: 'contain',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
rootMdSnapDirBoth: {
|
|
75
|
-
[theme.breakpoints.up('md')]: {
|
|
76
|
-
overflow: 'auto',
|
|
77
|
-
overscrollBehavior: 'contain',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
rootSmGridDirBlock: ({ scrollSnapAlign, scrollSnapStop }) => ({
|
|
82
|
-
display: 'grid',
|
|
83
|
-
gridAutoFlow: 'row',
|
|
84
|
-
gridAutoColumns: `40%`,
|
|
85
|
-
'& > *': {
|
|
86
|
-
scrollSnapAlign,
|
|
87
|
-
scrollSnapStop,
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
rootSmGridDirInline: ({ scrollSnapAlign, scrollSnapStop }) => ({
|
|
91
|
-
display: 'grid',
|
|
92
|
-
gridAutoFlow: 'column',
|
|
93
|
-
gridAutoRows: `40%`,
|
|
94
|
-
gridTemplateRows: 'auto',
|
|
95
|
-
'& > *': {
|
|
96
|
-
scrollSnapAlign,
|
|
97
|
-
scrollSnapStop,
|
|
98
|
-
},
|
|
99
|
-
}),
|
|
100
|
-
rootCanGrab: {
|
|
101
|
-
cursor: 'grab',
|
|
102
|
-
},
|
|
103
|
-
rootIsSnap: ({ scrollSnapTypeSm, scrollSnapTypeMd }: ScrollSnapProps) => ({
|
|
104
|
-
[theme.breakpoints.down('sm')]: {
|
|
105
|
-
scrollSnapType: scrollSnapTypeSm,
|
|
106
|
-
},
|
|
107
|
-
[theme.breakpoints.up('md')]: {
|
|
108
|
-
scrollSnapType: scrollSnapTypeMd,
|
|
109
|
-
},
|
|
110
|
-
}),
|
|
111
|
-
rootNoSnap: {
|
|
112
|
-
willChange: 'scroll-position',
|
|
113
|
-
},
|
|
114
|
-
rootIsPanning: {
|
|
115
|
-
cursor: 'grabbing !important',
|
|
116
|
-
'& > *': {
|
|
117
|
-
pointerEvents: 'none',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
rootHideScrollbar: {
|
|
121
|
-
scrollbarWidth: 'none',
|
|
122
|
-
'&::-webkit-scrollbar': {
|
|
123
|
-
display: 'none',
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
}),
|
|
127
|
-
{ name: 'Scroller' },
|
|
128
|
-
)
|
|
19
|
+
export type ScrollableProps<TagName extends keyof ReactHTML = 'div'> = HTMLMotionProps<TagName> & {
|
|
20
|
+
hideScrollbar?: boolean
|
|
21
|
+
grid?: boolean
|
|
22
|
+
}
|
|
129
23
|
|
|
130
|
-
|
|
131
|
-
|
|
24
|
+
type OwnerProps = {
|
|
25
|
+
smSnapDir: false | SnapTypeDirection
|
|
26
|
+
smGridDir: false | SnapTypeDirection
|
|
27
|
+
mdSnapDir: false | SnapTypeDirection
|
|
28
|
+
mdGridDir: false | SnapTypeDirection
|
|
29
|
+
isSnap: boolean
|
|
30
|
+
isPanning: boolean
|
|
31
|
+
hideScrollbar: boolean
|
|
32
|
+
canGrab: boolean
|
|
33
|
+
}
|
|
34
|
+
const name = 'Scroller' as const
|
|
35
|
+
const parts = ['root'] as const
|
|
36
|
+
const { withState } = extendableComponent<OwnerProps, typeof name, typeof parts>(name, parts)
|
|
132
37
|
|
|
133
38
|
/** Make any HTML */
|
|
134
39
|
export function useScroller<TagName extends keyof ReactHTML = 'div'>(
|
|
@@ -154,8 +59,6 @@ export function useScroller<TagName extends keyof ReactHTML = 'div'>(
|
|
|
154
59
|
|
|
155
60
|
const isSnap = useMotionValueValue(snap, (v) => v)
|
|
156
61
|
|
|
157
|
-
const classes = useStyles(scrollSnap)
|
|
158
|
-
|
|
159
62
|
const snapToVelocity = useVelocitySnapTo(scrollerRef)
|
|
160
63
|
|
|
161
64
|
const [isPanning, setPanning] = useState(false)
|
|
@@ -213,20 +116,161 @@ export function useScroller<TagName extends keyof ReactHTML = 'div'>(
|
|
|
213
116
|
const smSnapDir = scrollSnapTypeDirection(scrollSnap.scrollSnapTypeSm)
|
|
214
117
|
const mdSnapDir = scrollSnapTypeDirection(scrollSnap.scrollSnapTypeMd)
|
|
215
118
|
|
|
216
|
-
const
|
|
217
|
-
const mdGridDir = grid && mdSnapDir
|
|
218
|
-
|
|
219
|
-
const className = classesPicker(classes, {
|
|
119
|
+
const classes = withState({
|
|
220
120
|
smSnapDir,
|
|
221
|
-
smGridDir,
|
|
121
|
+
smGridDir: grid && smSnapDir,
|
|
222
122
|
mdSnapDir,
|
|
223
|
-
mdGridDir,
|
|
123
|
+
mdGridDir: grid && mdSnapDir,
|
|
224
124
|
isSnap,
|
|
225
|
-
noSnap: !isSnap,
|
|
226
125
|
isPanning,
|
|
227
126
|
hideScrollbar,
|
|
228
127
|
canGrab,
|
|
229
|
-
})
|
|
128
|
+
})
|
|
230
129
|
|
|
231
|
-
|
|
130
|
+
const sx: SxProps<Theme> = (theme) => ({
|
|
131
|
+
'& *': {
|
|
132
|
+
userSelect: 'none',
|
|
133
|
+
userDrag: 'none',
|
|
134
|
+
WebkitUserDrag: 'none',
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
// sm Snap Direction
|
|
138
|
+
'&.smSnapDirNone': {
|
|
139
|
+
[theme.breakpoints.down('md')]: {
|
|
140
|
+
overflow: 'hidden',
|
|
141
|
+
overscrollBehavior: 'auto',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
'&.smSnapDirBlock': {
|
|
145
|
+
[theme.breakpoints.down('md')]: {
|
|
146
|
+
overflowY: 'auto',
|
|
147
|
+
overflowX: 'hidden',
|
|
148
|
+
overscrollBehaviorBlock: 'contain',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
'&.smSnapDirInline': {
|
|
152
|
+
[theme.breakpoints.down('md')]: {
|
|
153
|
+
overflowX: 'auto',
|
|
154
|
+
overflowY: 'hidden',
|
|
155
|
+
overscrollBehaviorInline: 'contain',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
'&.smSnapDirBoth': {
|
|
159
|
+
[theme.breakpoints.down('md')]: {
|
|
160
|
+
overflow: 'auto',
|
|
161
|
+
overscrollBehavior: 'contain',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
// md Snap Direction
|
|
166
|
+
'&.mdSnapDirNone': {
|
|
167
|
+
[theme.breakpoints.up('md')]: {
|
|
168
|
+
overflow: 'hidden',
|
|
169
|
+
overscrollBehavior: 'auto',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
'&.mdSnapDirBlock': {
|
|
173
|
+
[theme.breakpoints.up('md')]: {
|
|
174
|
+
overflowY: 'auto',
|
|
175
|
+
overflowX: 'hidden',
|
|
176
|
+
overscrollBehaviorBlock: 'contain',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
'&.mdSnapDirInline': {
|
|
180
|
+
[theme.breakpoints.up('md')]: {
|
|
181
|
+
overflowX: 'auto',
|
|
182
|
+
overflowY: 'hidden',
|
|
183
|
+
overscrollBehaviorInline: 'contain',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
'&.mdSnapDirBoth': {
|
|
187
|
+
[theme.breakpoints.up('md')]: {
|
|
188
|
+
overflow: 'auto',
|
|
189
|
+
overscrollBehavior: 'contain',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
'&.smGridDirBlock': {
|
|
194
|
+
[theme.breakpoints.down('md')]: {
|
|
195
|
+
display: 'grid',
|
|
196
|
+
gridAutoFlow: 'row',
|
|
197
|
+
gridAutoColumns: `40%`,
|
|
198
|
+
'& > *': {
|
|
199
|
+
scrollSnapAlign: scrollSnap.scrollSnapAlign,
|
|
200
|
+
scrollSnapStop: scrollSnap.scrollSnapStop,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
'&.smGridDirInline': {
|
|
205
|
+
[theme.breakpoints.down('md')]: {
|
|
206
|
+
display: 'grid',
|
|
207
|
+
gridAutoFlow: 'column',
|
|
208
|
+
gridAutoRows: `40%`,
|
|
209
|
+
gridTemplateRows: 'auto',
|
|
210
|
+
'& > *': {
|
|
211
|
+
scrollSnapAlign: scrollSnap.scrollSnapAlign,
|
|
212
|
+
scrollSnapStop: scrollSnap.scrollSnapStop,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
'&.mdGridDirBlock': {
|
|
218
|
+
[theme.breakpoints.up('md')]: {
|
|
219
|
+
display: 'grid',
|
|
220
|
+
gridAutoFlow: 'row',
|
|
221
|
+
gridAutoColumns: `40%`,
|
|
222
|
+
'& > *': {
|
|
223
|
+
scrollSnapAlign: scrollSnap.scrollSnapAlign,
|
|
224
|
+
scrollSnapStop: scrollSnap.scrollSnapStop,
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
'&.mdGridDirInline': {
|
|
229
|
+
[theme.breakpoints.up('md')]: {
|
|
230
|
+
display: 'grid',
|
|
231
|
+
gridAutoFlow: 'column',
|
|
232
|
+
gridAutoRows: `40%`,
|
|
233
|
+
gridTemplateRows: 'auto',
|
|
234
|
+
'& > *': {
|
|
235
|
+
scrollSnapAlign: scrollSnap.scrollSnapAlign,
|
|
236
|
+
scrollSnapStop: scrollSnap.scrollSnapStop,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
'&.canGrab': { cursor: 'grab' },
|
|
241
|
+
'&.isSnap': {
|
|
242
|
+
[theme.breakpoints.down('md')]: {
|
|
243
|
+
scrollSnapType: scrollSnap.scrollSnapTypeSm,
|
|
244
|
+
},
|
|
245
|
+
[theme.breakpoints.up('md')]: {
|
|
246
|
+
scrollSnapType: scrollSnap.scrollSnapTypeMd,
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
'&:not(.isSnap)': {
|
|
250
|
+
willChange: 'scroll-position',
|
|
251
|
+
},
|
|
252
|
+
'&.isPanning': {
|
|
253
|
+
cursor: 'grabbing !important',
|
|
254
|
+
'& > *': {
|
|
255
|
+
pointerEvents: 'none',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
'&.hideScrollbar': {
|
|
259
|
+
scrollbarWidth: 'none',
|
|
260
|
+
'&::-webkit-scrollbar': {
|
|
261
|
+
display: 'none',
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
return {
|
|
267
|
+
...divProps,
|
|
268
|
+
ref,
|
|
269
|
+
onPanStart,
|
|
270
|
+
onPan,
|
|
271
|
+
onPanEnd,
|
|
272
|
+
children,
|
|
273
|
+
className: `${classes.root} ${props.className}`,
|
|
274
|
+
sx,
|
|
275
|
+
}
|
|
232
276
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Theme, useMediaQuery } from '@material
|
|
1
|
+
import { Theme, useMediaQuery } from '@mui/material'
|
|
2
2
|
import { PanInfo } from 'framer-motion'
|
|
3
3
|
import { inertia, InertiaOptions } from 'popmotion'
|
|
4
4
|
import { scrollSnapTypeDirection } from '../utils/scrollSnapTypeDirection'
|
|
@@ -21,7 +21,7 @@ export const useVelocitySnapTo = (
|
|
|
21
21
|
) => {
|
|
22
22
|
const { disableSnap, enableSnap, register, getScrollSnapPositions, scrollSnap } =
|
|
23
23
|
useScrollerContext()
|
|
24
|
-
const direction = useMediaQuery<Theme>((theme) => theme.breakpoints.down('
|
|
24
|
+
const direction = useMediaQuery<Theme>((theme) => theme.breakpoints.down('md'))
|
|
25
25
|
? scrollSnapTypeDirection(scrollSnap.scrollSnapTypeSm)
|
|
26
26
|
: scrollSnapTypeDirection(scrollSnap.scrollSnapTypeMd)
|
|
27
27
|
|
package/index.ts
CHANGED
|
@@ -18,6 +18,6 @@ export * from './components/ScrollerProvider'
|
|
|
18
18
|
export { default as ScrollerProvider } from './components/ScrollerProvider'
|
|
19
19
|
|
|
20
20
|
export * from './hooks/useScrollerContext'
|
|
21
|
-
export * from './hooks/useScroller'
|
|
21
|
+
// export * from './hooks/useScroller'
|
|
22
22
|
export * from './hooks/useScrollTo'
|
|
23
23
|
export * from './hooks/useWatchItems'
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/framer-scroller",
|
|
3
|
-
"
|
|
3
|
+
"homepage": "https://www.graphcommerce.org/",
|
|
4
|
+
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
+
"version": "2.0.2",
|
|
4
6
|
"sideEffects": false,
|
|
5
7
|
"scripts": {
|
|
6
8
|
"dev": "tsc -W"
|
|
7
9
|
},
|
|
8
10
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
9
|
-
"browserslist": [
|
|
10
|
-
"extends @graphcommerce/browserslist-config-pwa"
|
|
11
|
-
],
|
|
12
11
|
"eslintConfig": {
|
|
13
12
|
"extends": "@graphcommerce/eslint-config-pwa",
|
|
14
13
|
"parserOptions": {
|
|
@@ -16,25 +15,23 @@
|
|
|
16
15
|
}
|
|
17
16
|
},
|
|
18
17
|
"dependencies": {
|
|
19
|
-
"@graphcommerce/framer-utils": "^
|
|
20
|
-
"@graphcommerce/image": "^
|
|
21
|
-
"@graphcommerce/next-ui": "^
|
|
22
|
-
"@material-ui/core": "^4.12.3",
|
|
23
|
-
"popmotion": "11.0.3"
|
|
18
|
+
"@graphcommerce/framer-utils": "^3.0.2",
|
|
19
|
+
"@graphcommerce/image": "^3.0.2",
|
|
20
|
+
"@graphcommerce/next-ui": "^4.1.1"
|
|
24
21
|
},
|
|
25
22
|
"devDependencies": {
|
|
26
|
-
"@graphcommerce/
|
|
27
|
-
"@graphcommerce/
|
|
28
|
-
"@graphcommerce/
|
|
29
|
-
"@
|
|
30
|
-
"@playwright/test": "^1.17.1"
|
|
23
|
+
"@graphcommerce/eslint-config-pwa": "^4.0.2",
|
|
24
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.1",
|
|
25
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.1",
|
|
26
|
+
"@playwright/test": "^1.19.1"
|
|
31
27
|
},
|
|
32
28
|
"peerDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
29
|
+
"@mui/material": "^5.4.1",
|
|
30
|
+
"@lingui/macro": "^3.13.2",
|
|
31
|
+
"framer-motion": "^6.2.4",
|
|
32
|
+
"next": "^12.0.10",
|
|
33
|
+
"popmotion": "11.0.3",
|
|
35
34
|
"react": "^17.0.2",
|
|
36
|
-
"react-dom": "^17.0.2"
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
"gitHead": "41e42c8cd6f565ab0cbba81a1954a0041dc46768"
|
|
35
|
+
"react-dom": "^17.0.2"
|
|
36
|
+
}
|
|
40
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ScrollSnapType } from '../types'
|
|
2
2
|
|
|
3
|
-
type SnapTypeDirection = 'block' | 'inline' | 'both' | 'inline'
|
|
3
|
+
export type SnapTypeDirection = 'block' | 'inline' | 'both' | 'inline'
|
|
4
4
|
export function scrollSnapTypeDirection(scrollSnapType: ScrollSnapType): SnapTypeDirection {
|
|
5
5
|
let snapDir = scrollSnapType.split(' ')[0]
|
|
6
6
|
snapDir = snapDir.replace('y', 'block')
|