@graphcommerce/framer-scroller 2.1.14 → 2.1.17

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,39 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.1.17
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`371e6cf52`](https://github.com/graphcommerce-org/graphcommerce/commit/371e6cf52916a3b6c44192bd40cc8271bd608832), [`4143483f3`](https://github.com/graphcommerce-org/graphcommerce/commit/4143483f37c038d2bbf218be2685e27a31a35745)]:
8
+ - @graphcommerce/next-ui@4.10.0
9
+
10
+ ## 2.1.16
11
+
12
+ ### Patch Changes
13
+
14
+ - [#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
15
+
16
+ * [#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
17
+
18
+ * Updated dependencies [[`a9213f1f5`](https://github.com/graphcommerce-org/graphcommerce/commit/a9213f1f5a410d217768386ccb6d9b5ce7bd5782), [`d311ef48b`](https://github.com/graphcommerce-org/graphcommerce/commit/d311ef48bb3e97806d992af5516d6b7f183ec9cb)]:
19
+ - @graphcommerce/next-ui@4.9.0
20
+ - @graphcommerce/framer-utils@3.1.4
21
+ - @graphcommerce/image@3.1.7
22
+
23
+ ## 2.1.15
24
+
25
+ ### Patch Changes
26
+
27
+ - [#1509](https://github.com/graphcommerce-org/graphcommerce/pull/1509) [`0ab7c5465`](https://github.com/graphcommerce-org/graphcommerce/commit/0ab7c5465441cba9bf8cd185a6790ce2f443f4ed) Thanks [@paales](https://github.com/paales)! - SidebarGallery improvements (product page):
28
+
29
+ - Prevent vertical scrolling
30
+ - Disable zoom fab when there are no images
31
+ - Hide scroller dots when there in only one image
32
+ - Make sure the prev/next buttons are shown as expected
33
+
34
+ - Updated dependencies [[`0ab7c5465`](https://github.com/graphcommerce-org/graphcommerce/commit/0ab7c5465441cba9bf8cd185a6790ce2f443f4ed)]:
35
+ - @graphcommerce/next-ui@4.8.4
36
+
3
37
  ## 2.1.14
4
38
 
5
39
  ### Patch Changes
@@ -1,18 +1,22 @@
1
- import { useElementScroll } from '@graphcommerce/framer-utils'
2
- import { Fab, FabProps } from '@mui/material'
3
- import { m, useSpring, useTransform } from 'framer-motion'
1
+ import { useElementScroll, useMotionValueValue } from '@graphcommerce/framer-utils'
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
13
+ layout?: boolean
14
+ sxContainer?: SxProps<Theme>
11
15
  } & FabProps
12
16
 
13
17
  export const ScrollerButton = m(
14
18
  React.forwardRef<HTMLDivElement, ScrollerButtonProps>((props, ref) => {
15
- const { direction, sx = [], ...buttonProps } = props
19
+ const { direction, sx = [], layout, className, sxContainer, ...buttonProps } = props
16
20
 
17
21
  const { getSnapPosition, scrollerRef } = useScrollerContext()
18
22
  const scrollTo = useScrollTo()
@@ -20,39 +24,41 @@ export const ScrollerButton = m(
20
24
 
21
25
  const { xProgress, yProgress, xMax, yMax } = useElementScroll(scrollerRef)
22
26
 
23
- const progress = useTransform<number, number>(
24
- [xProgress, yProgress, xMax, yMax],
25
- ([x, y, xM, yM]) => {
27
+ const visibility = useMotionValueValue(
28
+ useTransform<number, number>([xProgress, yProgress, xMax, yMax], ([x, y, xM, yM]) => {
26
29
  if (xM === 0 && yM === 0) return 0
27
30
 
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
- }
40
- },
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
35
+
36
+ return 0
37
+ }),
38
+ (v) => v,
41
39
  )
42
- const scale = useSpring(progress)
43
40
 
44
41
  return (
45
- <m.div ref={ref} style={{ scale, opacity: scale, willChange: 'scale, opacity', zIndex: 1 }}>
42
+ <MotionDiv ref={ref} layout={layout} sx={sxContainer} className={className}>
46
43
  <Fab
47
44
  type='button'
48
45
  size='small'
49
46
  {...buttonProps}
50
47
  onClick={handleClick}
51
48
  aria-label={direction}
52
- sx={[{ display: { xs: 'none', md: 'flex' } }, ...(Array.isArray(sx) ? sx : [sx])]}
49
+ sx={[
50
+ {
51
+ display: { xs: 'none', md: 'flex' },
52
+ transition: 'all 250ms',
53
+ opacity: visibility,
54
+ transform: `scale(${visibility})`,
55
+ },
56
+ ...(Array.isArray(sx) ? sx : [sx]),
57
+ ]}
53
58
  />
54
- </m.div>
59
+ </MotionDiv>
55
60
  )
56
61
  }),
57
62
  )
63
+
58
64
  ScrollerButton.displayName = 'ScrollerButton'
@@ -23,6 +23,8 @@ export const ScrollerDots = m(
23
23
  const { items } = useScrollerContext()
24
24
  const itemsArr = useMotionValueValue(items, (v) => v)
25
25
 
26
+ if (itemsArr.length <= 1) return null
27
+
26
28
  return (
27
29
  <MotionBox
28
30
  {...containerProps}
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.14",
5
+ "version": "2.1.17",
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.3",
19
- "@graphcommerce/image": "3.1.6",
20
- "@graphcommerce/next-ui": "4.8.3"
18
+ "@graphcommerce/framer-utils": "3.1.4",
19
+ "@graphcommerce/image": "3.1.7",
20
+ "@graphcommerce/next-ui": "4.10.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@graphcommerce/eslint-config-pwa": "^4.1.7",
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": "^17.0.2",
36
- "react-dom": "^17.0.2"
35
+ "react": "^18.0.0",
36
+ "react-dom": "^18.0.0"
37
37
  }
38
38
  }