@graphcommerce/framer-scroller 2.1.9 → 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 CHANGED
@@ -1,5 +1,69 @@
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
+
16
+ ## 2.1.11
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [[`0363b9671`](https://github.com/graphcommerce-org/graphcommerce/commit/0363b9671db7c2932321d97faf6f1eb385238397), [`3ac90b57c`](https://github.com/graphcommerce-org/graphcommerce/commit/3ac90b57c68b96f9d81771d6664ed9435a28fc1d)]:
21
+ - @graphcommerce/next-ui@4.8.0
22
+
23
+ ## 2.1.10
24
+
25
+ ### Patch Changes
26
+
27
+ - [#1451](https://github.com/graphcommerce-org/graphcommerce/pull/1451) [`f698ff85d`](https://github.com/graphcommerce-org/graphcommerce/commit/f698ff85df6bb0922288471bb3c81856091b8061) Thanks [@paales](https://github.com/paales)! - Removed all occurences of @lingui/macro and moved to @lingui/macro / @lingui/core in preparation to move to swc.
28
+
29
+ Since we've removed @lingui/macro, all occurences need to be replaced with @lingui/core and @lingui/react.
30
+
31
+ All occurences of `<Trans>` and `t` need to be replaced:
32
+
33
+ ```tsx
34
+ import { Trans, t } from '@lingui/macro'
35
+
36
+ function MyComponent() {
37
+ const foo = 'bar'
38
+ return (
39
+ <div aria-label={t`Account ${foo}`}>
40
+ <Trans>My Translation {foo}</Trans>
41
+ </div>
42
+ )
43
+ }
44
+ ```
45
+
46
+ Needs to be replaced with:
47
+
48
+ ```tsx
49
+ import { Trans } from '@lingui/react'
50
+ import { i18n } from '@lingui/core'
51
+
52
+ function MyComponent() {
53
+ const foo = 'bar'
54
+ return (
55
+ <div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
56
+ <Trans key='My Translation {foo}' values={{ foo }}></Trans>
57
+ </div>
58
+ )
59
+ }
60
+ ```
61
+
62
+ [More examples for Trans](https://lingui.js.org/ref/macro.html#examples-of-jsx-macros) and [more examples for `t`](https://lingui.js.org/ref/macro.html#examples-of-js-macros)
63
+
64
+ - Updated dependencies [[`f698ff85d`](https://github.com/graphcommerce-org/graphcommerce/commit/f698ff85df6bb0922288471bb3c81856091b8061)]:
65
+ - @graphcommerce/next-ui@4.7.2
66
+
3
67
  ## 2.1.9
4
68
 
5
69
  ### 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, 1)
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
- if (direction === 'right' || direction === 'down') return x * y === 1 ? 0 : 1
28
- return x * y === 0 ? 0 : 1
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)
@@ -1,6 +1,6 @@
1
1
  import { useMotionValueValue } from '@graphcommerce/framer-utils'
2
2
  import { extendableComponent } from '@graphcommerce/next-ui/Styles'
3
- import { t } from '@lingui/macro'
3
+ import { i18n } from '@lingui/core'
4
4
  import { Fab, FabProps, styled } from '@mui/material'
5
5
  import { m } from 'framer-motion'
6
6
  import { useScrollTo } from '../hooks/useScrollTo'
@@ -37,7 +37,7 @@ export function ScrollerDot(props: ScrollerDotProps) {
37
37
  scrollTo({ x: positions.x[idx] ?? 0, y: positions.y[idx] ?? 0 })
38
38
  }}
39
39
  className={classes.dot}
40
- aria-label={t`Navigate to item ${idx + 1}`}
40
+ aria-label={i18n._(/* i18n */ 'Navigate to item {0}', { 0: idx + 1 })}
41
41
  sx={{
42
42
  boxShadow: 'none',
43
43
  background: 'transparent',
@@ -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 it is too slow we're not moving to that yet.
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: 500,
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: 500,
62
+ duration: 375,
58
63
  }),
59
64
  )
60
- } else onComplete()
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.x, scroll.y, scrollerRef],
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.9",
5
+ "version": "2.1.12",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"
@@ -15,19 +15,20 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "@graphcommerce/framer-utils": "3.1.2",
19
- "@graphcommerce/image": "3.1.5",
20
- "@graphcommerce/next-ui": "4.7.1"
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
- "@graphcommerce/eslint-config-pwa": "^4.1.6",
23
+ "@graphcommerce/eslint-config-pwa": "^4.1.7",
24
24
  "@graphcommerce/prettier-config-pwa": "^4.0.6",
25
- "@graphcommerce/typescript-config-pwa": "^4.0.2",
25
+ "@graphcommerce/typescript-config-pwa": "^4.0.3",
26
26
  "@playwright/test": "^1.21.1"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@mui/material": "5.5.3",
30
- "@lingui/macro": "^3.13.2",
30
+ "@lingui/react": "^3.13.2",
31
+ "@lingui/core": "^3.13.2",
31
32
  "framer-motion": "^6.2.4",
32
33
  "next": "12.1.2",
33
34
  "popmotion": "11.0.3",