@linear_non/stellar-libs 1.0.21 → 1.0.24
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 +2 -2
- package/src/Smooth/index.js +2 -10
- package/src/SplitOnScroll/index.js +15 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linear_non/stellar-libs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "Reusable JavaScript libraries for Non-Linear Studio projects.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "Non-Linear Studio",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@linear_non/stellar-kit": "^2.1.
|
|
28
|
+
"@linear_non/stellar-kit": "^2.1.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@linear_non/prettier-config": "^1.0.6",
|
package/src/Smooth/index.js
CHANGED
|
@@ -83,10 +83,8 @@ export default class Smooth {
|
|
|
83
83
|
const extra = (parent && parent.transform) || 0
|
|
84
84
|
const translate = this.current * speed
|
|
85
85
|
const transform = translate - offset - extra
|
|
86
|
-
|
|
87
86
|
const start = top - translate
|
|
88
87
|
const end = bottom - translate
|
|
89
|
-
|
|
90
88
|
const isVisible = end > 0 && start < vh
|
|
91
89
|
|
|
92
90
|
return { isVisible, transform }
|
|
@@ -102,7 +100,6 @@ export default class Smooth {
|
|
|
102
100
|
const { vh } = kitStore.sizes
|
|
103
101
|
const rect = bounds(el)
|
|
104
102
|
const height = rect.height
|
|
105
|
-
|
|
106
103
|
const centering = vh / 2 - height / 2
|
|
107
104
|
const offset = rect.top < vh ? 0 : (rect.top - centering) * speed - (rect.top - centering)
|
|
108
105
|
|
|
@@ -139,7 +136,7 @@ export default class Smooth {
|
|
|
139
136
|
kitStore.flags.isResizing = true
|
|
140
137
|
this.scroll.setScrollBounds()
|
|
141
138
|
this.elems = elems || qsa("[data-smooth]")
|
|
142
|
-
this.scrollbar
|
|
139
|
+
this.scrollbar?.update()
|
|
143
140
|
this.getSections()
|
|
144
141
|
this.transformSections()
|
|
145
142
|
kitStore.flags.isResizing = false
|
|
@@ -152,12 +149,6 @@ export default class Smooth {
|
|
|
152
149
|
on() {
|
|
153
150
|
emitter.on(EVENTS.APP_TICK, this.tick)
|
|
154
151
|
emitter.on(EVENTS.APP_RESIZE, this.resize)
|
|
155
|
-
|
|
156
|
-
if (document.readyState === "complete") {
|
|
157
|
-
this.update()
|
|
158
|
-
} else {
|
|
159
|
-
window.addEventListener("load", () => this.update(), { once: true })
|
|
160
|
-
}
|
|
161
152
|
}
|
|
162
153
|
|
|
163
154
|
off() {
|
|
@@ -173,5 +164,6 @@ export default class Smooth {
|
|
|
173
164
|
})
|
|
174
165
|
|
|
175
166
|
this.on()
|
|
167
|
+
this.update(this.elems)
|
|
176
168
|
}
|
|
177
169
|
}
|
|
@@ -6,7 +6,7 @@ export default class SplitonScroll {
|
|
|
6
6
|
constructor({
|
|
7
7
|
el,
|
|
8
8
|
splitText,
|
|
9
|
-
|
|
9
|
+
isReady,
|
|
10
10
|
reverse,
|
|
11
11
|
start = "top bottom", // "top top+=100%",
|
|
12
12
|
end = "bottom top", // "bottom bottom-=100%",
|
|
@@ -28,35 +28,22 @@ export default class SplitonScroll {
|
|
|
28
28
|
if (!this.targets.length) return
|
|
29
29
|
|
|
30
30
|
this.splits = null
|
|
31
|
-
|
|
32
|
-
this.animateCallback = animate || (() => {})
|
|
31
|
+
this.isReadyCallback = isReady || (() => {})
|
|
33
32
|
this.reverseCallback = reverse || (() => {})
|
|
34
33
|
this.start = start
|
|
35
34
|
this.end = end
|
|
36
35
|
this.scrub = scrub
|
|
37
36
|
this.once = once
|
|
38
37
|
|
|
39
|
-
// this.initScrollTrigger()
|
|
40
38
|
this.addObserver()
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
initScrollTrigger() {
|
|
44
|
-
this.myScrollTrigger = ScrollTrigger.create({
|
|
45
|
-
trigger: this.element,
|
|
46
|
-
start: this.start,
|
|
47
|
-
end: this.end,
|
|
48
|
-
scrub: this.scrub,
|
|
49
|
-
once: this.once,
|
|
50
|
-
onEnter: () => this.handleEnter(),
|
|
51
|
-
onLeave: () => this.handleLeave(),
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
55
41
|
addObserver() {
|
|
56
42
|
this.observer = new Observer({
|
|
57
43
|
trigger: this.element,
|
|
58
44
|
start: this.start,
|
|
59
45
|
end: this.end,
|
|
46
|
+
once: this.once,
|
|
60
47
|
scrub: this.scrub,
|
|
61
48
|
})
|
|
62
49
|
|
|
@@ -64,15 +51,20 @@ export default class SplitonScroll {
|
|
|
64
51
|
this.observer.on("leave", () => this.handleLeave())
|
|
65
52
|
}
|
|
66
53
|
|
|
67
|
-
handleEnter() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.hasSplit = true
|
|
54
|
+
async handleEnter() {
|
|
55
|
+
if (this.splits) {
|
|
56
|
+
this.isReadyCallback(this.splits)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
73
59
|
|
|
74
|
-
|
|
60
|
+
const split = splitText(this.targets)
|
|
61
|
+
const splits = await new Promise(resolve => {
|
|
62
|
+
split.on(EVENTS.APP_SPLITTEXT_READY, readySplits => {
|
|
63
|
+
resolve(readySplits)
|
|
64
|
+
})
|
|
75
65
|
})
|
|
66
|
+
this.splits = splits
|
|
67
|
+
this.isReadyCallback(splits)
|
|
76
68
|
}
|
|
77
69
|
|
|
78
70
|
handleLeave() {
|
|
@@ -93,7 +85,6 @@ export default class SplitonScroll {
|
|
|
93
85
|
|
|
94
86
|
destroy() {
|
|
95
87
|
this.observer?.kill()
|
|
96
|
-
|
|
97
88
|
this.splits = null
|
|
98
89
|
this.targets = null
|
|
99
90
|
this.element = null
|