@graphcommerce/framer-scroller 9.0.0-canary.98 → 9.0.0
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 +60 -1051
- package/components/MotionImageAspect.tsx +3 -2
- package/components/Scroller.tsx +4 -2
- package/components/ScrollerBar.tsx +5 -3
- package/components/ScrollerButton.tsx +4 -3
- package/components/ScrollerDot.tsx +4 -3
- package/components/ScrollerDots.tsx +3 -2
- package/components/ScrollerPageCounter.tsx +2 -1
- package/components/ScrollerProvider.tsx +6 -5
- package/components/ScrollerThumbnail.tsx +11 -3
- package/components/ScrollerThumbnails.tsx +2 -2
- package/components/ThumbnailContainer.tsx +5 -3
- package/context/scrollerContext.ts +1 -1
- package/hooks/useScrollTo.ts +5 -4
- package/hooks/useScroller.ts +23 -21
- package/hooks/useScrollerContext.ts +1 -1
- package/hooks/useScrollerControl.ts +1 -1
- package/hooks/useVelocitySnapTo.ts +4 -3
- package/hooks/useWatchItems.ts +1 -1
- package/package.json +7 -7
- package/types.ts +4 -4
- package/utils/scrollSnapTypeDirection.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ImageProps } from '@graphcommerce/image'
|
|
2
|
+
import { Image } from '@graphcommerce/image'
|
|
2
3
|
import { Box } from '@mui/material'
|
|
3
4
|
import { m } from 'framer-motion'
|
|
4
5
|
import { forwardRef } from 'react'
|
|
@@ -12,7 +13,7 @@ export type MotionImageAspectProps = Omit<ImageProps, 'layout' | 'unoptimized'>
|
|
|
12
13
|
* Note: We have a fallback for Safari 14 which doesn't yet support aspect-ratio, this causes a
|
|
13
14
|
* problem when the layout is animated. Should be fixed in Safari 15
|
|
14
15
|
*/
|
|
15
|
-
export const MotionImageAspect = m(
|
|
16
|
+
export const MotionImageAspect = m.create(
|
|
16
17
|
forwardRef<HTMLImageElement, MotionImageAspectProps>((props, ref) => (
|
|
17
18
|
<Box
|
|
18
19
|
className='MotionImageAspect'
|
package/components/Scroller.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
2
|
+
import { styled } from '@mui/material'
|
|
2
3
|
import { m } from 'framer-motion'
|
|
3
4
|
import { forwardRef } from 'react'
|
|
4
|
-
import { ScrollableProps
|
|
5
|
+
import type { ScrollableProps } from '../hooks/useScroller'
|
|
6
|
+
import { useScroller } from '../hooks/useScroller'
|
|
5
7
|
|
|
6
8
|
const ScrollerDiv = styled(m.div)({})
|
|
7
9
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import { extendableComponent } from '@graphcommerce/next-ui/Styles'
|
|
3
|
-
import {
|
|
3
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
4
|
+
import { styled, useTheme } from '@mui/material'
|
|
4
5
|
import { m, transform, useTransform } from 'framer-motion'
|
|
5
6
|
import { useRef } from 'react'
|
|
6
7
|
import { useScrollerContext } from '../hooks/useScrollerContext'
|
|
@@ -10,7 +11,7 @@ type OwnerProps = {
|
|
|
10
11
|
direction: 'x' | 'y'
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
type ScrollerBarProps = OwnerProps & {
|
|
14
|
+
export type ScrollerBarProps = OwnerProps & {
|
|
14
15
|
sx?: SxProps<Theme>
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -36,6 +37,7 @@ const Scroll = styled(m.button)({
|
|
|
36
37
|
height: 7,
|
|
37
38
|
})
|
|
38
39
|
|
|
40
|
+
/** @public */
|
|
39
41
|
export function ScrollerBar(props: ScrollerBarProps) {
|
|
40
42
|
const { direction, sx } = props
|
|
41
43
|
const control = useScrollerControl()
|
|
@@ -52,7 +54,7 @@ export function ScrollerBar(props: ScrollerBarProps) {
|
|
|
52
54
|
|
|
53
55
|
const scrollProgress = scroll[`${direction}Progress`]
|
|
54
56
|
|
|
55
|
-
const thumbSize = useTransform(scrollProgress, (
|
|
57
|
+
const thumbSize = useTransform(scrollProgress, () => {
|
|
56
58
|
if (!scrollerRef.current) return 0
|
|
57
59
|
const trackWidth = scrollerRef.current[offsetSize]
|
|
58
60
|
return trackWidth * (trackWidth / scrollerRef.current[scrollSize])
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
|
-
import {
|
|
2
|
+
import type { FabProps, SxProps, Theme } from '@mui/material'
|
|
3
|
+
import { Fab, styled } from '@mui/material'
|
|
3
4
|
import { m, useTransform } from 'framer-motion'
|
|
4
5
|
import React from 'react'
|
|
5
6
|
import { useScrollTo } from '../hooks/useScrollTo'
|
|
6
7
|
import { useScrollerContext } from '../hooks/useScrollerContext'
|
|
7
|
-
import { SnapPositionDirection } from '../types'
|
|
8
|
+
import type { SnapPositionDirection } from '../types'
|
|
8
9
|
|
|
9
10
|
const MotionDiv = styled(m.div)({})
|
|
10
11
|
|
|
@@ -15,7 +16,7 @@ export type ScrollerButtonProps = {
|
|
|
15
16
|
showButtons?: 'auto' | 'desktopAuto' | 'always' | 'desktopAlways' | 'never'
|
|
16
17
|
} & FabProps
|
|
17
18
|
|
|
18
|
-
export const ScrollerButton = m(
|
|
19
|
+
export const ScrollerButton = m.create(
|
|
19
20
|
React.forwardRef<HTMLDivElement, ScrollerButtonProps>((props, ref) => {
|
|
20
21
|
const {
|
|
21
22
|
direction,
|
|
@@ -2,11 +2,12 @@ import { useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
import { extendableComponent } from '@graphcommerce/next-ui/Styles'
|
|
4
4
|
import { i18n } from '@lingui/core'
|
|
5
|
-
import {
|
|
5
|
+
import type { FabProps } from '@mui/material'
|
|
6
|
+
import { Fab, styled } from '@mui/material'
|
|
6
7
|
import { m } from 'framer-motion'
|
|
7
8
|
import { useScrollTo } from '../hooks/useScrollTo'
|
|
8
9
|
import { useScrollerContext } from '../hooks/useScrollerContext'
|
|
9
|
-
import { ItemState } from '../types'
|
|
10
|
+
import type { ItemState } from '../types'
|
|
10
11
|
|
|
11
12
|
const name = 'ScrollerDot'
|
|
12
13
|
const parts = ['dot', 'circle'] as const
|
|
@@ -14,7 +15,7 @@ type OwnerProps = { active: boolean }
|
|
|
14
15
|
|
|
15
16
|
const { withState } = extendableComponent<OwnerProps, typeof name, typeof parts>(name, parts)
|
|
16
17
|
|
|
17
|
-
type ScrollerDotProps = Omit<FabProps, 'onClick' | 'className'> & ItemState & { idx: number }
|
|
18
|
+
export type ScrollerDotProps = Omit<FabProps, 'onClick' | 'className'> & ItemState & { idx: number }
|
|
18
19
|
|
|
19
20
|
const MotionBox = styled(m.div)({})
|
|
20
21
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
import { extendableComponent } from '@graphcommerce/next-ui/Styles'
|
|
4
|
-
import {
|
|
4
|
+
import type { FabProps, SxProps, Theme } from '@mui/material'
|
|
5
|
+
import { Box } from '@mui/material'
|
|
5
6
|
import { m } from 'framer-motion'
|
|
6
7
|
import React from 'react'
|
|
7
8
|
import { useScrollerContext } from '../hooks/useScrollerContext'
|
|
@@ -15,7 +16,7 @@ export type DotsProps = {
|
|
|
15
16
|
const componentName = 'ScrollerDots'
|
|
16
17
|
const { classes } = extendableComponent(componentName, ['root', 'dot', 'circle'] as const)
|
|
17
18
|
|
|
18
|
-
export const ScrollerDots = m(
|
|
19
|
+
export const ScrollerDots = m.create(
|
|
19
20
|
React.forwardRef<HTMLDivElement, DotsProps>((props, ref) => {
|
|
20
21
|
const { fabProps, sx = [], ...containerProps } = props
|
|
21
22
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
|
-
import {
|
|
2
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
3
|
+
import { styled } from '@mui/material'
|
|
3
4
|
import { m } from 'framer-motion'
|
|
4
5
|
import React, { useState } from 'react'
|
|
5
6
|
import { useScrollerContext } from '../hooks/useScrollerContext'
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { useConstant, useElementScroll } from '@graphcommerce/framer-utils'
|
|
2
|
-
import { MotionValue,
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import type { MotionValue, Point } from 'framer-motion'
|
|
3
|
+
import { motionValue, useDomEvent, useMotionValue } from 'framer-motion'
|
|
4
|
+
import type { PlaybackControls } from 'popmotion'
|
|
5
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react'
|
|
5
6
|
import { scrollerContext } from '../context/scrollerContext'
|
|
6
|
-
import {
|
|
7
|
+
import type {
|
|
7
8
|
Axis,
|
|
8
9
|
ItemState,
|
|
9
10
|
ReactHtmlRefObject,
|
|
10
|
-
ScrollerContext,
|
|
11
11
|
ScrollSnapAlign,
|
|
12
12
|
ScrollSnapAlignAxis,
|
|
13
13
|
ScrollSnapStop,
|
|
14
14
|
ScrollSnapType,
|
|
15
|
+
ScrollerContext,
|
|
15
16
|
SnapPositionList,
|
|
16
17
|
} from '../types'
|
|
17
18
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
|
-
import {
|
|
2
|
+
import type { ImageProps } from '@graphcommerce/image'
|
|
3
|
+
import { Image } from '@graphcommerce/image'
|
|
3
4
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
5
|
import { extendableComponent, responsiveVal } from '@graphcommerce/next-ui/Styles'
|
|
5
6
|
import { alpha, styled, useTheme } from '@mui/material'
|
|
@@ -13,7 +14,7 @@ type OwnerProps = { active: boolean }
|
|
|
13
14
|
|
|
14
15
|
const { withState } = extendableComponent<OwnerProps, typeof name, typeof parts>(name, parts)
|
|
15
16
|
|
|
16
|
-
type ScrollerThumbnailProps = {
|
|
17
|
+
export type ScrollerThumbnailProps = {
|
|
17
18
|
idx: number
|
|
18
19
|
image: Pick<ImageProps, 'src' | 'height' | 'width'>
|
|
19
20
|
layoutDependency: boolean
|
|
@@ -44,7 +45,7 @@ export function ScrollerThumbnail(props: ScrollerThumbnailProps) {
|
|
|
44
45
|
theme.palette.primary.main,
|
|
45
46
|
theme.palette.action.hoverOpacity,
|
|
46
47
|
)}`,
|
|
47
|
-
|
|
48
|
+
'inset 0 0 0 2px #ffffff00, 0 0 0 4px #ffffff00',
|
|
48
49
|
],
|
|
49
50
|
)
|
|
50
51
|
|
|
@@ -53,8 +54,15 @@ export function ScrollerThumbnail(props: ScrollerThumbnailProps) {
|
|
|
53
54
|
const scrollIntoView = () =>
|
|
54
55
|
ref.current?.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior: 'auto' })
|
|
55
56
|
|
|
57
|
+
const initialRender = useRef(true)
|
|
58
|
+
|
|
56
59
|
useEffect(() => {
|
|
57
60
|
if (active && ref.current) {
|
|
61
|
+
// Skip scrollIntoView on initial render
|
|
62
|
+
if (initialRender.current) {
|
|
63
|
+
initialRender.current = false
|
|
64
|
+
return
|
|
65
|
+
}
|
|
58
66
|
// This is a hack to ensure that the scroll animation is finished.
|
|
59
67
|
setTimeout(() => scrollIntoView(), 1)
|
|
60
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImageProps } from '@graphcommerce/image'
|
|
2
|
-
import { ButtonProps, SxProps, Theme } from '@mui/material'
|
|
1
|
+
import type { ImageProps } from '@graphcommerce/image'
|
|
2
|
+
import type { ButtonProps, SxProps, Theme } from '@mui/material'
|
|
3
3
|
import { ScrollerThumbnail } from './ScrollerThumbnail'
|
|
4
4
|
import { ThumbnailContainer } from './ThumbnailContainer'
|
|
5
5
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
2
|
+
import { styled } from '@mui/material'
|
|
3
|
+
import type { PanHandlers } from 'framer-motion'
|
|
4
|
+
import { m } from 'framer-motion'
|
|
3
5
|
import React, { useRef } from 'react'
|
|
4
6
|
|
|
5
7
|
const MotionBox = styled(m.div)({})
|
|
6
8
|
|
|
7
|
-
type ThumbnailContainerProps = {
|
|
9
|
+
export type ThumbnailContainerProps = {
|
|
8
10
|
children: React.ReactNode
|
|
9
11
|
sx?: SxProps<Theme>
|
|
10
12
|
layoutDependency: boolean
|
package/hooks/useScrollTo.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Point, Tween } from 'framer-motion'
|
|
2
|
+
import { MotionConfigContext } from 'framer-motion'
|
|
2
3
|
import { animate } from 'popmotion'
|
|
3
4
|
import { useCallback, useContext } from 'react'
|
|
4
5
|
import { distanceAnimationDuration } from '../utils/distanceAnimationDuration'
|
|
@@ -40,20 +41,20 @@ export function useScrollTo() {
|
|
|
40
41
|
(Math.round(ref.scrollLeft) !== to.x || Math.round(ref.scrollTop) !== to.y)
|
|
41
42
|
) {
|
|
42
43
|
console.warn(
|
|
43
|
-
|
|
44
|
+
'scrollTo triggered while another animation is in progress. This cancels the current animation and creates a new one.',
|
|
44
45
|
)
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
if (process.env.NODE_ENV === 'development' && __retrigger > 5) {
|
|
48
49
|
console.error(
|
|
49
|
-
|
|
50
|
+
'scrollTo triggered more than 5 times, is the element resizing constantly? Bailing out.',
|
|
50
51
|
)
|
|
51
52
|
return
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
if (process.env.NODE_ENV === 'development' && __retrigger > 0) {
|
|
55
56
|
console.warn(
|
|
56
|
-
|
|
57
|
+
'scrollTo re-animating to because the final location changed during animation.',
|
|
57
58
|
)
|
|
58
59
|
}
|
|
59
60
|
|
package/hooks/useScroller.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { useConstant, useMotionValueValue } from '@graphcommerce/framer-utils'
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
import { extendableComponent } from '@graphcommerce/next-ui/Styles'
|
|
4
|
-
import { SxProps, Theme } from '@mui/material'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
PanInfo,
|
|
11
|
-
useTransform,
|
|
12
|
-
} from 'framer-motion'
|
|
13
|
-
import React, { MouseEventHandler, ReactHTML, useEffect, useState } from 'react'
|
|
4
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
5
|
+
import type { HTMLMotionProps, MotionValue, PanHandlers, PanInfo } from 'framer-motion'
|
|
6
|
+
import { motionValue, useTransform } from 'framer-motion'
|
|
7
|
+
import type { MouseEventHandler, ReactHTML } from 'react'
|
|
8
|
+
import type React from 'react'
|
|
9
|
+
import { useEffect, useState } from 'react'
|
|
14
10
|
import { isHTMLMousePointerEvent } from '../utils/isHTMLMousePointerEvent'
|
|
15
|
-
import {
|
|
11
|
+
import type { SnapTypeDirection } from '../utils/scrollSnapTypeDirection'
|
|
12
|
+
import { scrollSnapTypeDirection } from '../utils/scrollSnapTypeDirection'
|
|
16
13
|
import { useScrollerContext } from './useScrollerContext'
|
|
17
14
|
import { useVelocitySnapTo } from './useVelocitySnapTo'
|
|
18
15
|
|
|
@@ -23,6 +20,7 @@ export type ScrollableProps<TagName extends keyof ReactHTML = 'div'> = Omit<
|
|
|
23
20
|
hideScrollbar?: boolean
|
|
24
21
|
grid?: boolean
|
|
25
22
|
children: React.ReactNode
|
|
23
|
+
disableDrag?: boolean
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
type OwnerProps = {
|
|
@@ -36,7 +34,8 @@ type OwnerProps = {
|
|
|
36
34
|
canGrab: boolean
|
|
37
35
|
grid: boolean
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
|
|
38
|
+
const name = 'Scroller'
|
|
40
39
|
const parts = ['root'] as const
|
|
41
40
|
const { withState } = extendableComponent<OwnerProps, typeof name, typeof parts>(name, parts)
|
|
42
41
|
|
|
@@ -45,7 +44,7 @@ export function useScroller<
|
|
|
45
44
|
TagName extends keyof ReactHTML = 'div',
|
|
46
45
|
E extends HTMLElement = HTMLElement,
|
|
47
46
|
>(props: ScrollableProps<TagName>, forwardedRef: React.ForwardedRef<E>) {
|
|
48
|
-
const { hideScrollbar = false, children, grid = false, ...divProps } = props
|
|
47
|
+
const { hideScrollbar = false, children, grid = false, disableDrag, ...divProps } = props
|
|
49
48
|
|
|
50
49
|
const { scrollSnap, scrollerRef, disableSnap, snap, registerChildren, scroll } =
|
|
51
50
|
useScrollerContext()
|
|
@@ -55,10 +54,7 @@ export function useScroller<
|
|
|
55
54
|
}, [children, registerChildren])
|
|
56
55
|
|
|
57
56
|
const canGrab = useMotionValueValue(
|
|
58
|
-
useTransform(
|
|
59
|
-
[scroll.xMax, scroll.yMax] as MotionValue<string | number>[],
|
|
60
|
-
([xMax, yMax]: number[]) => xMax || yMax,
|
|
61
|
-
),
|
|
57
|
+
useTransform(() => !disableDrag && (scroll.xMax.get() || scroll.yMax.get())),
|
|
62
58
|
(v) => !!v,
|
|
63
59
|
)
|
|
64
60
|
|
|
@@ -70,6 +66,8 @@ export function useScroller<
|
|
|
70
66
|
|
|
71
67
|
const scrollStart = useConstant(() => ({ x: motionValue(0), y: motionValue(0) }))
|
|
72
68
|
const onPanStart: PanHandlers['onPanStart'] = (event) => {
|
|
69
|
+
if (disableDrag) return
|
|
70
|
+
|
|
73
71
|
// If we're not dealing with the mouse we don't need to do anything
|
|
74
72
|
if (!isHTMLMousePointerEvent(event)) return
|
|
75
73
|
|
|
@@ -98,6 +96,8 @@ export function useScroller<
|
|
|
98
96
|
}
|
|
99
97
|
|
|
100
98
|
const onPan: PanHandlers['onPan'] = (event, info: PanInfo) => {
|
|
99
|
+
if (disableDrag) return
|
|
100
|
+
|
|
101
101
|
if (!scrollerRef.current) return
|
|
102
102
|
|
|
103
103
|
// If we're not dealing with the mouse we don't need to do anything
|
|
@@ -111,6 +111,8 @@ export function useScroller<
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
const onPanEnd: PanHandlers['onPanEnd'] = (event, info) => {
|
|
114
|
+
if (disableDrag) return
|
|
115
|
+
|
|
114
116
|
// If we're not dealing with the mouse we don't need to do anything
|
|
115
117
|
if (!isHTMLMousePointerEvent(event)) return
|
|
116
118
|
if (!isPanning) return
|
|
@@ -208,7 +210,7 @@ export function useScroller<
|
|
|
208
210
|
[theme.breakpoints.down('md')]: {
|
|
209
211
|
display: 'grid',
|
|
210
212
|
gridAutoFlow: 'row',
|
|
211
|
-
gridAutoColumns:
|
|
213
|
+
gridAutoColumns: '40%',
|
|
212
214
|
'& > *': {
|
|
213
215
|
scrollSnapAlign: scrollSnap.scrollSnapAlign,
|
|
214
216
|
scrollSnapStop: scrollSnap.scrollSnapStop,
|
|
@@ -219,7 +221,7 @@ export function useScroller<
|
|
|
219
221
|
[theme.breakpoints.down('md')]: {
|
|
220
222
|
display: 'grid',
|
|
221
223
|
gridAutoFlow: 'column',
|
|
222
|
-
gridAutoRows:
|
|
224
|
+
gridAutoRows: '40%',
|
|
223
225
|
gridTemplateRows: 'auto',
|
|
224
226
|
'& > *': {
|
|
225
227
|
scrollSnapAlign: scrollSnap.scrollSnapAlign,
|
|
@@ -232,7 +234,7 @@ export function useScroller<
|
|
|
232
234
|
[theme.breakpoints.up('md')]: {
|
|
233
235
|
display: 'grid',
|
|
234
236
|
gridAutoFlow: 'row',
|
|
235
|
-
gridAutoColumns:
|
|
237
|
+
gridAutoColumns: '40%',
|
|
236
238
|
'& > *': {
|
|
237
239
|
scrollSnapAlign: scrollSnap.scrollSnapAlign,
|
|
238
240
|
scrollSnapStop: scrollSnap.scrollSnapStop,
|
|
@@ -243,7 +245,7 @@ export function useScroller<
|
|
|
243
245
|
[theme.breakpoints.up('md')]: {
|
|
244
246
|
display: 'grid',
|
|
245
247
|
gridAutoFlow: 'column',
|
|
246
|
-
gridAutoRows:
|
|
248
|
+
gridAutoRows: '40%',
|
|
247
249
|
gridTemplateRows: 'auto',
|
|
248
250
|
'& > *': {
|
|
249
251
|
scrollSnapAlign: scrollSnap.scrollSnapAlign,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext } from 'react'
|
|
2
2
|
import { scrollerContext } from '../context/scrollerContext'
|
|
3
|
-
import { ScrollerContext } from '../types'
|
|
3
|
+
import type { ScrollerContext } from '../types'
|
|
4
4
|
|
|
5
5
|
export function useScrollerContext(): ScrollerContext {
|
|
6
6
|
return useContext(scrollerContext)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useConstant } from '@graphcommerce/framer-utils'
|
|
2
|
-
import { PanInfo, Point } from 'framer-motion'
|
|
2
|
+
import type { PanInfo, Point } from 'framer-motion'
|
|
3
3
|
import { useScrollerContext } from './useScrollerContext'
|
|
4
4
|
import { useVelocitySnapTo } from './useVelocitySnapTo'
|
|
5
5
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import { useMatchMedia } from '@graphcommerce/next-ui/hooks/useMatchMedia'
|
|
3
|
-
import { PanInfo } from 'framer-motion'
|
|
4
|
-
import {
|
|
3
|
+
import type { PanInfo } from 'framer-motion'
|
|
4
|
+
import type { InertiaOptions } from 'popmotion'
|
|
5
|
+
import { inertia } from 'popmotion'
|
|
5
6
|
import { scrollSnapTypeDirection } from '../utils/scrollSnapTypeDirection'
|
|
6
7
|
import { useScrollerContext } from './useScrollerContext'
|
|
7
8
|
|
|
@@ -43,7 +44,7 @@ export const useVelocitySnapTo = (
|
|
|
43
44
|
|
|
44
45
|
const animatePan = async (info: LimitedPanInfo) => {
|
|
45
46
|
const el = ref.current
|
|
46
|
-
if (!el) throw Error(
|
|
47
|
+
if (!el) throw Error("Can't find html element")
|
|
47
48
|
|
|
48
49
|
const { scrollLeft, scrollTop } = el
|
|
49
50
|
|
package/hooks/useWatchItems.ts
CHANGED
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": "9.0.0
|
|
5
|
+
"version": "9.0.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "tsc -W"
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"popmotion": "11.0.5"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0
|
|
22
|
-
"@graphcommerce/framer-utils": "^9.0.0
|
|
23
|
-
"@graphcommerce/image": "^9.0.0
|
|
24
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0
|
|
25
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0
|
|
21
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0",
|
|
22
|
+
"@graphcommerce/framer-utils": "^9.0.0",
|
|
23
|
+
"@graphcommerce/image": "^9.0.0",
|
|
24
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0",
|
|
25
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0",
|
|
26
26
|
"@lingui/core": "^4.2.1",
|
|
27
27
|
"@lingui/react": "^4.2.1",
|
|
28
28
|
"@mui/material": "^5.10.16",
|
|
29
|
-
"framer-motion": "^
|
|
29
|
+
"framer-motion": "^11.0.0",
|
|
30
30
|
"next": "*",
|
|
31
31
|
"react": "^18.2.0",
|
|
32
32
|
"react-dom": "^18.2.0"
|
package/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ScrollMotionValues } from '@graphcommerce/framer-utils'
|
|
2
|
-
import { MotionValue, Point } from 'framer-motion'
|
|
3
|
-
import { PlaybackControls } from 'popmotion'
|
|
4
|
-
import React from 'react'
|
|
1
|
+
import type { ScrollMotionValues } from '@graphcommerce/framer-utils'
|
|
2
|
+
import type { MotionValue, Point } from 'framer-motion'
|
|
3
|
+
import type { PlaybackControls } from 'popmotion'
|
|
4
|
+
import type React from 'react'
|
|
5
5
|
|
|
6
6
|
export type ItemState = {
|
|
7
7
|
el?: HTMLElement
|