@linear_non/stellar-libs 1.2.3 → 1.2.4
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 +1 -1
- package/src/Sticky/index.js +6 -2
package/package.json
CHANGED
package/src/Sticky/index.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
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"
|
|
4
5
|
|
|
5
6
|
export default class Sticky {
|
|
6
7
|
constructor(obj) {
|
|
7
|
-
const { el, sticky, isSmooth, onUpdateCallback } = obj
|
|
8
|
+
const { el, sticky, container, isSmooth, onUpdateCallback } = obj
|
|
8
9
|
|
|
9
10
|
this.el = el
|
|
10
11
|
this.sticky = sticky
|
|
11
12
|
this.isSticky = false
|
|
12
13
|
this.isSmooth = isSmooth
|
|
14
|
+
this.container = container
|
|
13
15
|
this.progress = 0
|
|
14
16
|
this.total = 0
|
|
15
17
|
this.positionX = 0
|
|
@@ -39,6 +41,7 @@ export default class Sticky {
|
|
|
39
41
|
start: "top top",
|
|
40
42
|
end: "bottom bottom",
|
|
41
43
|
scrub: true,
|
|
44
|
+
scroller: kitStore.scroller || undefined,
|
|
42
45
|
onEnter: () => this.toggleSticky(true),
|
|
43
46
|
onEnterBack: () => this.toggleSticky(true),
|
|
44
47
|
onLeave: () => this.toggleSticky(false, true),
|
|
@@ -97,7 +100,8 @@ export default class Sticky {
|
|
|
97
100
|
// Get the viewport height dynamically instead of using store
|
|
98
101
|
const vh = window.innerHeight
|
|
99
102
|
let stickyRect = bounds(this.el)
|
|
100
|
-
|
|
103
|
+
let containerRect = this.container ? bounds(this.container) : null
|
|
104
|
+
this.config.totalWidth = containerRect ? this.snap(containerRect.width - vh) : 0
|
|
101
105
|
this.config.totalHeight = this.snap(stickyRect.height - vh)
|
|
102
106
|
}
|
|
103
107
|
|