@graphcommerce/framer-scroller 0.2.6 → 0.2.10

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
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [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)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **framer-scroller:** dots should have a background ([8f2e1a1](https://github.com/ho-nl/m2-pwa/commit/8f2e1a1ffc9de3369938fe2f9e9f25f592739d8d))
12
+
13
+
14
+
15
+
16
+
17
+ ## [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)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **framer-scroller:** pan snap does not work on mobile ([660f242](https://github.com/ho-nl/m2-pwa/commit/660f242a38558669fa896a74e14cafdd85069d57))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [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)
7
29
 
8
30
 
@@ -1,4 +1,5 @@
1
1
  import { useMotionValueValue } from '@graphcommerce/framer-utils'
2
+ import { UseStyles } from '@graphcommerce/next-ui'
2
3
  import { Fab, FabProps, makeStyles, Theme } from '@material-ui/core'
3
4
  import clsx from 'clsx'
4
5
  import { HTMLMotionProps, m } from 'framer-motion'
@@ -6,11 +7,6 @@ import React from 'react'
6
7
  import { useScrollTo } from '../hooks/useScrollTo'
7
8
  import { useScrollerContext } from '../hooks/useScrollerContext'
8
9
 
9
- export type DotsProps = {
10
- classes?: Record<'dots' | 'dot' | 'circle', string>
11
- fabProps?: Omit<FabProps, 'onClick' | 'children'>
12
- } & HTMLMotionProps<'div'>
13
-
14
10
  const useStyles = makeStyles(
15
11
  (theme: Theme) => ({
16
12
  dots: {
@@ -18,6 +14,7 @@ const useStyles = makeStyles(
18
14
  display: 'grid',
19
15
  gridAutoFlow: 'column',
20
16
  padding: `0 7px`,
17
+ borderRadius: '20px',
21
18
  },
22
19
  dot: {
23
20
  boxShadow: 'none',
@@ -34,8 +31,13 @@ const useStyles = makeStyles(
34
31
  { name: 'ScrollerDots' },
35
32
  )
36
33
 
34
+ export type DotsProps = {
35
+ fabProps?: Omit<FabProps, 'onClick' | 'children'>
36
+ } & HTMLMotionProps<'div'> &
37
+ UseStyles<typeof useStyles>
38
+
37
39
  const ScrollerDots = m(
38
- React.forwardRef<any, DotsProps>((props, ref) => {
40
+ React.forwardRef<HTMLDivElement, DotsProps>((props, ref) => {
39
41
  const { fabProps, ...containerProps } = props
40
42
  const { dots, dot, circle, ...classes } = useStyles(props)
41
43
  const { items, getScrollSnapPositions } = useScrollerContext()
@@ -3,13 +3,12 @@ import { makeStyles } from '@material-ui/core'
3
3
  import clsx from 'clsx'
4
4
  import {
5
5
  HTMLMotionProps,
6
- PanInfo,
7
6
  motionValue,
8
- useDomEvent,
7
+ MotionValue,
9
8
  PanHandlers,
10
- m,
9
+ PanInfo,
10
+ useDomEvent,
11
11
  useTransform,
12
- MotionValue,
13
12
  } from 'framer-motion'
14
13
  import React, { ReactHTML, useState } from 'react'
15
14
  import { ScrollSnapProps } from '../types'
@@ -100,7 +99,10 @@ export function useScroller<TagName extends keyof ReactHTML = 'div'>(
100
99
  })
101
100
 
102
101
  const scrollStart = useConstant(() => ({ x: motionValue(0), y: motionValue(0) }))
103
- const onPanStart: PanHandlers['onPanStart'] = () => {
102
+ const onPanStart: PanHandlers['onPanStart'] = (event) => {
103
+ // If we're not dealing with the mouse we don't need to do anything
104
+ if (!isHTMLMousePointerEvent(event)) return
105
+
104
106
  scrollStart.x.set(scroll.x.get())
105
107
  scrollStart.y.set(scroll.y.get())
106
108
  disableSnap()
@@ -120,6 +122,7 @@ export function useScroller<TagName extends keyof ReactHTML = 'div'>(
120
122
  const onPanEnd: PanHandlers['onPanEnd'] = (event, info) => {
121
123
  // If we're not dealing with the mouse we don't need to do anything
122
124
  if (!isHTMLMousePointerEvent(event)) return
125
+
123
126
  setPanning(false)
124
127
  animatePan(info, enableSnap)
125
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/framer-scroller",
3
- "version": "0.2.6",
3
+ "version": "0.2.10",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "dev": "tsc -W"
@@ -16,16 +16,16 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@graphcommerce/framer-utils": "^2.103.5",
20
- "@graphcommerce/image": "^2.104.6",
19
+ "@graphcommerce/framer-utils": "^2.103.7",
20
+ "@graphcommerce/image": "^2.104.9",
21
21
  "@material-ui/core": "^4.12.3",
22
22
  "popmotion": "9.3.6"
23
23
  },
24
24
  "devDependencies": {
25
- "@graphcommerce/browserslist-config-pwa": "^3.0.1",
26
- "@graphcommerce/eslint-config-pwa": "^3.0.5",
27
- "@graphcommerce/prettier-config-pwa": "^3.0.2",
28
- "@graphcommerce/typescript-config-pwa": "^3.1.0",
25
+ "@graphcommerce/browserslist-config-pwa": "^3.0.2",
26
+ "@graphcommerce/eslint-config-pwa": "^3.0.6",
27
+ "@graphcommerce/prettier-config-pwa": "^3.0.3",
28
+ "@graphcommerce/typescript-config-pwa": "^3.1.1",
29
29
  "@playwright/test": "^1.15.0"
30
30
  },
31
31
  "peerDependencies": {
@@ -35,5 +35,5 @@
35
35
  "react-dom": "^17.0.2",
36
36
  "type-fest": "^1.0.1"
37
37
  },
38
- "gitHead": "f1d0e488921787f39a260c410790ec13d32c8143"
38
+ "gitHead": "06977d2e65b4ab4eb4a472fc56f8b1a99512f1bd"
39
39
  }
@@ -1,22 +0,0 @@
1
- import { useEffect } from 'react'
2
- import { ItemState } from '../types'
3
- import { useScrollerContext } from './useScrollerContext'
4
-
5
- export function useWatchItems(callback: (item: ItemState, items: ItemState[]) => void) {
6
- const { items } = useScrollerContext()
7
-
8
- useEffect(() => {
9
- const watched: (() => void)[] = []
10
-
11
- const handleItemChange = (itemArr: ItemState[]) => {
12
- itemArr.forEach((item) => {
13
- watched.push(item.visibility.onChange(() => callback(item, items.get())))
14
- })
15
- }
16
-
17
- watched.push(items.onChange(handleItemChange))
18
- handleItemChange(items.get())
19
-
20
- return () => watched.forEach((w) => w())
21
- })
22
- }