@graphcommerce/framer-utils 3.0.4 → 3.0.5

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,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1322](https://github.com/graphcommerce-org/graphcommerce/pull/1322) [`bec88d0d7`](https://github.com/graphcommerce-org/graphcommerce/commit/bec88d0d70b679e15150917df89986ecee5b39a6) Thanks [@paales](https://github.com/paales)! - ScrollerButton is rendered while it shouldn’t because there is a rounding error in scroll and offset values
8
+
3
9
  ## 3.0.4
4
10
 
5
11
  ### Patch Changes
@@ -30,23 +30,22 @@ export function useElementScroll(
30
30
  const element = ref?.current
31
31
  if (!element) return () => {}
32
32
 
33
- const setProgress = (offset: number, maxOffset: number, value: MotionValue) => {
34
- value.set(!offset && !maxOffset ? noScroll : offset / maxOffset)
35
- }
36
-
37
33
  const updater = () => {
38
34
  sync.read(() => {
39
35
  const { scrollLeft, scrollTop, scrollWidth, scrollHeight, offsetWidth, offsetHeight } =
40
36
  element
41
37
 
38
+ const xMax = Math.max(0, scrollWidth - offsetWidth)
39
+ const yMax = Math.max(0, scrollHeight - offsetHeight)
40
+
42
41
  values.x.set(scrollLeft)
43
42
  values.y.set(scrollTop)
44
- values.xMax.set(scrollWidth - offsetWidth)
45
- values.yMax.set(scrollHeight - offsetHeight)
43
+ values.xMax.set(xMax)
44
+ values.yMax.set(yMax)
46
45
 
47
46
  // Set 0-1 progress
48
- setProgress(scrollLeft, scrollWidth - offsetWidth, values.xProgress)
49
- setProgress(scrollTop, scrollHeight - offsetHeight, values.yProgress)
47
+ values.xProgress.set(!scrollLeft && !xMax ? noScroll : scrollLeft / xMax)
48
+ values.yProgress.set(!scrollTop && !yMax ? noScroll : scrollTop / yMax)
50
49
  })
51
50
  }
52
51
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/framer-utils",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "3.0.4",
5
+ "version": "3.0.5",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"