@linear_non/stellar-libs 1.0.35 → 1.0.36
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/ScrollBar/index.js +0 -1
- package/src/Smooth/index.js +17 -2
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.36",
|
|
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.7"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@linear_non/prettier-config": "^1.0.6",
|
package/src/ScrollBar/index.js
CHANGED
package/src/Smooth/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// Smooth.js
|
|
2
1
|
import Scrollbar from "../ScrollBar"
|
|
3
2
|
import { kitStore } from "@linear_non/stellar-kit"
|
|
4
3
|
import { emitter, EVENTS } from "@linear_non/stellar-kit/events"
|
|
@@ -16,6 +15,12 @@ export default class Smooth {
|
|
|
16
15
|
this.init()
|
|
17
16
|
}
|
|
18
17
|
|
|
18
|
+
/**
|
|
19
|
+
* - top / bottom: virtual layout positions
|
|
20
|
+
* - offset: parallax centering adjustment
|
|
21
|
+
* - speed: dataset speed multiplier
|
|
22
|
+
* - parent: optional reference to another section for nested offsets
|
|
23
|
+
*/
|
|
19
24
|
getSections() {
|
|
20
25
|
const { isSmooth } = kitStore.flags
|
|
21
26
|
if (!this.elems || !isSmooth) return
|
|
@@ -81,10 +86,13 @@ export default class Smooth {
|
|
|
81
86
|
const { top, bottom, offset, speed, parent } = section
|
|
82
87
|
|
|
83
88
|
const extra = (parent && parent.transform) || 0
|
|
89
|
+
|
|
84
90
|
const translate = this.current * speed
|
|
85
91
|
const transform = translate - offset - extra
|
|
92
|
+
|
|
86
93
|
const start = top - translate
|
|
87
94
|
const end = bottom - translate
|
|
95
|
+
|
|
88
96
|
const isVisible = end > 0 && start < vh
|
|
89
97
|
|
|
90
98
|
return { isVisible, transform }
|
|
@@ -93,6 +101,7 @@ export default class Smooth {
|
|
|
93
101
|
getTransform(transform) {
|
|
94
102
|
let y = -transform
|
|
95
103
|
y = Math.round(y * this.dpr) / this.dpr
|
|
104
|
+
|
|
96
105
|
return `translate3d(0, ${y}px, 0)`
|
|
97
106
|
}
|
|
98
107
|
|
|
@@ -156,11 +165,17 @@ export default class Smooth {
|
|
|
156
165
|
emitter.off(EVENTS.APP_RESIZE, this.resize)
|
|
157
166
|
}
|
|
158
167
|
|
|
168
|
+
destroy() {
|
|
169
|
+
this.off()
|
|
170
|
+
this.clean()
|
|
171
|
+
}
|
|
172
|
+
|
|
159
173
|
init(elems) {
|
|
160
174
|
this.elems = elems || qsa("[data-smooth]")
|
|
161
175
|
|
|
176
|
+
const container = kitStore.currentPage
|
|
162
177
|
this.scrollbar = new Scrollbar({
|
|
163
|
-
container
|
|
178
|
+
container,
|
|
164
179
|
})
|
|
165
180
|
|
|
166
181
|
this.on()
|