@graphcommerce/framer-scroller 2.1.15 → 2.1.16
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 +20 -25
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.1.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1511](https://github.com/graphcommerce-org/graphcommerce/pull/1511) [`ddb6d6329`](https://github.com/graphcommerce-org/graphcommerce/commit/ddb6d6329bfad361b2fbe96402ca2bfc0ab3d98c) Thanks [@paales](https://github.com/paales)! - make sure the header is clickable when no forward/prev buttons are shown
|
|
8
|
+
|
|
9
|
+
* [#1490](https://github.com/graphcommerce-org/graphcommerce/pull/1490) [`d311ef48b`](https://github.com/graphcommerce-org/graphcommerce/commit/d311ef48bb3e97806d992af5516d6b7f183ec9cb) Thanks [@paales](https://github.com/paales)! - upgraded packages
|
|
10
|
+
|
|
11
|
+
* Updated dependencies [[`a9213f1f5`](https://github.com/graphcommerce-org/graphcommerce/commit/a9213f1f5a410d217768386ccb6d9b5ce7bd5782), [`d311ef48b`](https://github.com/graphcommerce-org/graphcommerce/commit/d311ef48bb3e97806d992af5516d6b7f183ec9cb)]:
|
|
12
|
+
- @graphcommerce/next-ui@4.9.0
|
|
13
|
+
- @graphcommerce/framer-utils@3.1.4
|
|
14
|
+
- @graphcommerce/image@3.1.7
|
|
15
|
+
|
|
3
16
|
## 2.1.15
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { useElementScroll, useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
|
-
import { Fab, FabProps } from '@mui/material'
|
|
3
|
-
import { m,
|
|
2
|
+
import { Fab, FabProps, styled, SxProps, Theme } from '@mui/material'
|
|
3
|
+
import { m, 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
7
|
import { SnapPositionDirection } from '../types'
|
|
8
8
|
|
|
9
|
+
const MotionDiv = styled(m.div)({})
|
|
10
|
+
|
|
9
11
|
export type ScrollerButtonProps = {
|
|
10
12
|
direction: SnapPositionDirection
|
|
11
13
|
layout?: boolean
|
|
14
|
+
sxContainer?: SxProps<Theme>
|
|
12
15
|
} & FabProps
|
|
13
16
|
|
|
14
17
|
export const ScrollerButton = m(
|
|
15
18
|
React.forwardRef<HTMLDivElement, ScrollerButtonProps>((props, ref) => {
|
|
16
|
-
const { direction, sx = [], layout, ...buttonProps } = props
|
|
19
|
+
const { direction, sx = [], layout, className, sxContainer, ...buttonProps } = props
|
|
17
20
|
|
|
18
21
|
const { getSnapPosition, scrollerRef } = useScrollerContext()
|
|
19
22
|
const scrollTo = useScrollTo()
|
|
@@ -21,30 +24,22 @@ export const ScrollerButton = m(
|
|
|
21
24
|
|
|
22
25
|
const { xProgress, yProgress, xMax, yMax } = useElementScroll(scrollerRef)
|
|
23
26
|
|
|
24
|
-
const
|
|
25
|
-
[xProgress, yProgress, xMax, yMax],
|
|
26
|
-
([x, y, xM, yM]) => {
|
|
27
|
+
const visibility = useMotionValueValue(
|
|
28
|
+
useTransform<number, number>([xProgress, yProgress, xMax, yMax], ([x, y, xM, yM]) => {
|
|
27
29
|
if (xM === 0 && yM === 0) return 0
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return x > 0.9 ? 0 : 1
|
|
34
|
-
case 'up':
|
|
35
|
-
return y < 0.1 ? 0 : 1
|
|
36
|
-
case 'down':
|
|
37
|
-
return y > 0.9 ? 0 : 1
|
|
38
|
-
default:
|
|
39
|
-
return 0
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
)
|
|
31
|
+
if (direction === 'left') return x < 0.1 ? 0 : 1
|
|
32
|
+
if (direction === 'right') return x > 0.9 ? 0 : 1
|
|
33
|
+
if (direction === 'up') return y < 0.1 ? 0 : 1
|
|
34
|
+
if (direction === 'down') return y > 0.9 ? 0 : 1
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+
return 0
|
|
37
|
+
}),
|
|
38
|
+
(v) => v,
|
|
39
|
+
)
|
|
45
40
|
|
|
46
41
|
return (
|
|
47
|
-
<
|
|
42
|
+
<MotionDiv ref={ref} layout={layout} sx={sxContainer} className={className}>
|
|
48
43
|
<Fab
|
|
49
44
|
type='button'
|
|
50
45
|
size='small'
|
|
@@ -55,13 +50,13 @@ export const ScrollerButton = m(
|
|
|
55
50
|
{
|
|
56
51
|
display: { xs: 'none', md: 'flex' },
|
|
57
52
|
transition: 'all 250ms',
|
|
58
|
-
opacity:
|
|
59
|
-
transform: `scale(${
|
|
53
|
+
opacity: visibility,
|
|
54
|
+
transform: `scale(${visibility})`,
|
|
60
55
|
},
|
|
61
56
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
62
57
|
]}
|
|
63
58
|
/>
|
|
64
|
-
</
|
|
59
|
+
</MotionDiv>
|
|
65
60
|
)
|
|
66
61
|
}),
|
|
67
62
|
)
|
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.16",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "tsc -W"
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@graphcommerce/framer-utils": "3.1.
|
|
19
|
-
"@graphcommerce/image": "3.1.
|
|
20
|
-
"@graphcommerce/next-ui": "4.
|
|
18
|
+
"@graphcommerce/framer-utils": "3.1.4",
|
|
19
|
+
"@graphcommerce/image": "3.1.7",
|
|
20
|
+
"@graphcommerce/next-ui": "4.9.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
23
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.8",
|
|
24
24
|
"@graphcommerce/prettier-config-pwa": "^4.0.6",
|
|
25
25
|
"@graphcommerce/typescript-config-pwa": "^4.0.3",
|
|
26
26
|
"@playwright/test": "^1.21.1"
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@lingui/react": "^3.13.2",
|
|
31
31
|
"@lingui/core": "^3.13.2",
|
|
32
32
|
"framer-motion": "^6.2.4",
|
|
33
|
-
"next": "12.1.2",
|
|
33
|
+
"next": "^12.1.2",
|
|
34
34
|
"popmotion": "11.0.3",
|
|
35
|
-
"react": "^
|
|
36
|
-
"react-dom": "^
|
|
35
|
+
"react": "^18.0.0",
|
|
36
|
+
"react-dom": "^18.0.0"
|
|
37
37
|
}
|
|
38
38
|
}
|