@linear_non/stellar-libs 1.0.35 → 1.0.37

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.0.35",
3
+ "version": "1.0.37",
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.5"
28
+ "@linear_non/stellar-kit": "^2.1.9"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@linear_non/prettier-config": "^1.0.6",
@@ -1,4 +1,3 @@
1
- // Scrollbar.js
2
1
  import { kitStore } from "@linear_non/stellar-kit"
3
2
  import { emitter, EVENTS, Raf } from "@linear_non/stellar-kit/events"
4
3
 
@@ -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: kitStore.currentPage,
178
+ container,
164
179
  })
165
180
 
166
181
  this.on()
@@ -57,7 +57,6 @@ export default class SplitonScroll {
57
57
 
58
58
  this.addObserver()
59
59
 
60
- // If already in view, trigger enter handler
61
60
  if (this.observer.isActive || this.observer.progress > 0) {
62
61
  this.handleEnter()
63
62
  }
@@ -77,11 +76,6 @@ export default class SplitonScroll {
77
76
  }
78
77
 
79
78
  async handleEnter() {
80
- if (this.splits) {
81
- this.isReadyCallback(this.splits, this.groups || {})
82
- return
83
- }
84
-
85
79
  const emitter = splitText(this.targets)
86
80
 
87
81
  const { splits, groups } = await new Promise(resolve => {