@linear_non/stellar-libs 1.0.13 → 1.0.15
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/SplitOnScroll/index.js +25 -3
- package/src/SpritePlayer/index.js +13 -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.15",
|
|
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": "^
|
|
28
|
+
"@linear_non/stellar-kit": "^2.0.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@linear_non/prettier-config": "^1.0.6",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { splitText, reverseSplit } from "@linear_non/stellar-kit/
|
|
1
|
+
import { splitText, reverseSplit, Observer } from "@linear_non/stellar-kit/plugins"
|
|
2
2
|
import { EVENTS } from "@linear_non/stellar-kit/events"
|
|
3
3
|
import { ScrollTrigger } from "@linear_non/stellar-kit/gsap"
|
|
4
4
|
|
|
@@ -25,7 +25,9 @@ export default class SplitonScroll {
|
|
|
25
25
|
|
|
26
26
|
if (!this.splitText[0]) return
|
|
27
27
|
|
|
28
|
-
this.initScrollTrigger()
|
|
28
|
+
// this.initScrollTrigger()
|
|
29
|
+
|
|
30
|
+
this.addObserver()
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
initScrollTrigger() {
|
|
@@ -40,7 +42,19 @@ export default class SplitonScroll {
|
|
|
40
42
|
})
|
|
41
43
|
}
|
|
42
44
|
|
|
45
|
+
addObserver() {
|
|
46
|
+
this.observer = new Observer({
|
|
47
|
+
trigger: this.element,
|
|
48
|
+
start: this.start,
|
|
49
|
+
end: this.end,
|
|
50
|
+
scrub: this.scrub,
|
|
51
|
+
})
|
|
52
|
+
this.observer.on("enter", () => this.handleEnter())
|
|
53
|
+
this.observer.on("leave", () => this.handleLeave())
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
handleEnter() {
|
|
57
|
+
console.log("jojo")
|
|
44
58
|
const split = splitText(this.splitText)
|
|
45
59
|
split.on(EVENTS.APP_SPLITTEXT_READY, splits => {
|
|
46
60
|
this.splits = [...splits]
|
|
@@ -51,6 +65,14 @@ export default class SplitonScroll {
|
|
|
51
65
|
handleLeave() {
|
|
52
66
|
reverseSplit(this.splits)
|
|
53
67
|
this.reverseCallback()
|
|
54
|
-
this.
|
|
68
|
+
this.destroy()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
update() {
|
|
72
|
+
this.observer?.refresh()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
destroy() {
|
|
76
|
+
this.observer?.kill()
|
|
55
77
|
}
|
|
56
78
|
}
|
|
@@ -101,10 +101,20 @@ export default class SpritePlayer {
|
|
|
101
101
|
const onProgress = e => emitter.emit("sprite:progress", { instance: this, ...e })
|
|
102
102
|
emitter.on(ImageLoader.events.PROGRESS, onProgress)
|
|
103
103
|
|
|
104
|
+
const wantAlphaUrls = Array.isArray(alpha_urls) && alpha_urls.length > 0
|
|
105
|
+
const wantAlphaPath = !!(originAlpha && fileAlpha)
|
|
106
|
+
|
|
104
107
|
const [images, alphaImages] = await Promise.all([
|
|
108
|
+
// base: urls[] wins; otherwise origin+file_name pattern
|
|
105
109
|
make({ origin: originBase, fileName: file_name, list: urls }),
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
|
|
111
|
+
// alpha: load if EITHER urls[] OR path+file is provided
|
|
112
|
+
wantAlphaUrls || wantAlphaPath
|
|
113
|
+
? make({
|
|
114
|
+
origin: wantAlphaUrls ? null : originAlpha,
|
|
115
|
+
fileName: wantAlphaUrls ? null : fileAlpha,
|
|
116
|
+
list: wantAlphaUrls ? alpha_urls : null,
|
|
117
|
+
})
|
|
108
118
|
: Promise.resolve([]),
|
|
109
119
|
])
|
|
110
120
|
|
|
@@ -144,6 +154,7 @@ export default class SpritePlayer {
|
|
|
144
154
|
Object.assign(this.canvas, { width: rect.width, height: rect.height, rect, area, offset })
|
|
145
155
|
}
|
|
146
156
|
|
|
157
|
+
// grayscale → alpha (returns a canvas)
|
|
147
158
|
toAlphaFromLuma(img) {
|
|
148
159
|
const w = img.naturalWidth || img.width
|
|
149
160
|
const h = img.naturalHeight || img.height
|