@linear_non/stellar-libs 1.2.2 → 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.2",
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",
@@ -1,7 +1,6 @@
1
1
  // Sticky.js
2
2
  import { bounds } from "@linear_non/stellar-kit/utils"
3
3
  import { gsap, ScrollTrigger } from "@linear_non/stellar-kit/gsap"
4
- import { kitStore } from "@linear_non/stellar-kit/kitStore"
5
4
 
6
5
  export default class Sticky {
7
6
  constructor(obj) {
@@ -18,6 +17,9 @@ export default class Sticky {
18
17
  this.scrollTrigger = null
19
18
  this.onUpdateCallback = typeof onUpdateCallback === "function" ? onUpdateCallback : null
20
19
 
20
+ this.dpr = Math.max(1, Math.round(window.devicePixelRatio || 1))
21
+ this.snap = v => Math.round(v * this.dpr) / this.dpr
22
+
21
23
  this.config = {
22
24
  width: 0,
23
25
  height: 0,
@@ -37,7 +39,6 @@ export default class Sticky {
37
39
  start: "top top",
38
40
  end: "bottom bottom",
39
41
  scrub: true,
40
- scroller: kitStore.scroller || undefined,
41
42
  onEnter: () => this.toggleSticky(true),
42
43
  onEnterBack: () => this.toggleSticky(true),
43
44
  onLeave: () => this.toggleSticky(false, true),
@@ -66,8 +67,8 @@ export default class Sticky {
66
67
  onUpdate(self) {
67
68
  const { totalWidth, totalHeight } = this.config
68
69
  const newProgress = self.progress
69
- const newY = newProgress * totalHeight
70
- const newX = -newProgress * totalWidth
70
+ const newY = this.snap(newProgress * totalHeight)
71
+ const newX = this.snap(-newProgress * totalWidth)
71
72
 
72
73
  // Only update if values change to prevent unnecessary calls
73
74
  if (this.progress !== newProgress || this.positionY !== newY || this.positionX !== newX) {
@@ -76,7 +77,7 @@ export default class Sticky {
76
77
  this.positionX = newX
77
78
 
78
79
  if (this.isSmooth) {
79
- gsap.set(this.sticky, { y: this.positionY })
80
+ gsap.set(this.sticky, { y: this.positionY, force3D: true })
80
81
  }
81
82
 
82
83
  // Call the callback function if provided
@@ -97,9 +98,7 @@ export default class Sticky {
97
98
  const vh = window.innerHeight
98
99
  let stickyRect = bounds(this.el)
99
100
 
100
- Object.assign(this.config, {
101
- totalHeight: stickyRect.height - vh,
102
- })
101
+ this.config.totalHeight = this.snap(stickyRect.height - vh)
103
102
  }
104
103
 
105
104
  destroy() {