@linear_non/stellar-libs 1.2.1 → 1.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linear_non/stellar-libs",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Reusable JavaScript libraries for Non-Linear Studio projects.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -17,6 +17,9 @@ export default class Sticky {
17
17
  this.scrollTrigger = null
18
18
  this.onUpdateCallback = typeof onUpdateCallback === "function" ? onUpdateCallback : null
19
19
 
20
+ this.dpr = Math.max(1, Math.round(window.devicePixelRatio || 1))
21
+ this.snap = v => Math.round(v * this.dpr) / this.dpr
22
+
20
23
  this.config = {
21
24
  width: 0,
22
25
  height: 0,
@@ -64,8 +67,8 @@ export default class Sticky {
64
67
  onUpdate(self) {
65
68
  const { totalWidth, totalHeight } = this.config
66
69
  const newProgress = self.progress
67
- const newY = newProgress * totalHeight
68
- const newX = -newProgress * totalWidth
70
+ const newY = this.snap(newProgress * totalHeight)
71
+ const newX = this.snap(-newProgress * totalWidth)
69
72
 
70
73
  // Only update if values change to prevent unnecessary calls
71
74
  if (this.progress !== newProgress || this.positionY !== newY || this.positionX !== newX) {
@@ -74,7 +77,7 @@ export default class Sticky {
74
77
  this.positionX = newX
75
78
 
76
79
  if (this.isSmooth) {
77
- gsap.set(this.sticky, { y: this.positionY })
80
+ gsap.set(this.sticky, { y: this.positionY, force3D: true })
78
81
  }
79
82
 
80
83
  // Call the callback function if provided
@@ -95,9 +98,7 @@ export default class Sticky {
95
98
  const vh = window.innerHeight
96
99
  let stickyRect = bounds(this.el)
97
100
 
98
- Object.assign(this.config, {
99
- totalHeight: stickyRect.height - vh,
100
- })
101
+ this.config.totalHeight = this.snap(stickyRect.height - vh)
101
102
  }
102
103
 
103
104
  destroy() {