@brandocms/jupiter 5.0.0-beta.4 → 5.0.0-beta.6
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": "@brandocms/jupiter",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.6",
|
|
4
4
|
"description": "Frontend helpers.",
|
|
5
5
|
"author": "Univers/Twined",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -42,16 +42,14 @@
|
|
|
42
42
|
},
|
|
43
43
|
"types": "types/index.d.ts",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"body-scroll-lock": "^4.0.0-beta.0",
|
|
46
45
|
"lodash.defaultsdeep": "^4.6.1",
|
|
47
|
-
"motion": "^12.23.
|
|
48
|
-
"virtual-scroll": "^2.2.1"
|
|
46
|
+
"motion": "^12.23.26"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
|
-
"@playwright/test": "^1.
|
|
52
|
-
"@types/node": "^22.
|
|
53
|
-
"typescript": "^5.
|
|
54
|
-
"vite": "^6.
|
|
49
|
+
"@playwright/test": "^1.57.0",
|
|
50
|
+
"@types/node": "^22.19.3",
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"vite": "^6.4.1"
|
|
55
53
|
},
|
|
56
54
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
57
55
|
}
|
|
@@ -83,6 +83,65 @@ export default class Lazyload {
|
|
|
83
83
|
this.initObserver(this.revealObserver, false)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Observe new lazyload elements within a container
|
|
88
|
+
* Handles both [data-ll-image] and [data-ll-srcset] elements
|
|
89
|
+
* Useful for dynamically added content (e.g., Looper clones)
|
|
90
|
+
* @param {HTMLElement|HTMLElement[]|NodeList} elements - Container element(s) or lazyload element(s) to observe
|
|
91
|
+
*/
|
|
92
|
+
observe(elements) {
|
|
93
|
+
// Handle NodeList, array, or single element
|
|
94
|
+
const els = elements instanceof NodeList ? Array.from(elements) :
|
|
95
|
+
Array.isArray(elements) ? elements : [elements]
|
|
96
|
+
|
|
97
|
+
let imgIdx = this.lazyImages?.length || 0
|
|
98
|
+
let picIdx = this.lazyPictures?.length || 0
|
|
99
|
+
|
|
100
|
+
els.forEach(el => {
|
|
101
|
+
// Handle [data-ll-image] elements
|
|
102
|
+
if (this.imageObserver) {
|
|
103
|
+
const images = el.matches?.('[data-ll-image]')
|
|
104
|
+
? [el]
|
|
105
|
+
: el.querySelectorAll?.('[data-ll-image]') || []
|
|
106
|
+
|
|
107
|
+
images.forEach(img => {
|
|
108
|
+
// Skip if already observed or loaded
|
|
109
|
+
if (img.hasAttribute('data-ll-idx') || img.hasAttribute('data-ll-loaded')) return
|
|
110
|
+
|
|
111
|
+
img.setAttribute('data-ll-blurred', '')
|
|
112
|
+
img.setAttribute('data-ll-idx', imgIdx)
|
|
113
|
+
img.style.setProperty('--ll-idx', imgIdx)
|
|
114
|
+
this.imageObserver.observe(img)
|
|
115
|
+
imgIdx++
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Handle [data-ll-srcset] picture elements
|
|
120
|
+
if (this.loadObserver) {
|
|
121
|
+
const pictures = el.matches?.('[data-ll-srcset]')
|
|
122
|
+
? [el]
|
|
123
|
+
: el.querySelectorAll?.('[data-ll-srcset]') || []
|
|
124
|
+
|
|
125
|
+
pictures.forEach(picture => {
|
|
126
|
+
// Skip if already loaded
|
|
127
|
+
if (picture.hasAttribute('data-ll-srcset-ready')) return
|
|
128
|
+
|
|
129
|
+
picture.setAttribute('data-ll-srcset-initialized', '')
|
|
130
|
+
picture.querySelectorAll('img:not([data-ll-loaded])').forEach(img => {
|
|
131
|
+
img.removeAttribute('data-ll-idx') // Clear cloned idx
|
|
132
|
+
img.setAttribute('data-ll-blurred', '')
|
|
133
|
+
img.setAttribute('data-ll-idx', picIdx)
|
|
134
|
+
img.style.setProperty('--ll-idx', picIdx)
|
|
135
|
+
})
|
|
136
|
+
// Add to both observers like initObserver does
|
|
137
|
+
this.loadObserver.observe(picture)
|
|
138
|
+
this.revealObserver?.observe(picture)
|
|
139
|
+
picIdx++
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
86
145
|
initialize() {
|
|
87
146
|
// initialize ResizeObserver for images with data-sizes="auto"
|
|
88
147
|
this.initializeResizeObserver()
|
|
@@ -128,12 +187,7 @@ export default class Lazyload {
|
|
|
128
187
|
)
|
|
129
188
|
|
|
130
189
|
this.lazyImages = this.target.querySelectorAll('[data-ll-image]')
|
|
131
|
-
this.lazyImages
|
|
132
|
-
img.setAttribute('data-ll-blurred', '')
|
|
133
|
-
img.setAttribute('data-ll-idx', idx)
|
|
134
|
-
img.style.setProperty('--ll-idx', idx)
|
|
135
|
-
this.imageObserver.observe(img)
|
|
136
|
-
})
|
|
190
|
+
this.observe(this.lazyImages)
|
|
137
191
|
}
|
|
138
192
|
|
|
139
193
|
initObserver(observer, setAttrs = true) {
|
|
@@ -182,6 +182,30 @@ function horizontalLoop(app, items, config) {
|
|
|
182
182
|
clone.setAttribute('data-looper-clone', 'true')
|
|
183
183
|
container.appendChild(clone)
|
|
184
184
|
items.push(clone)
|
|
185
|
+
|
|
186
|
+
// Register cloned lazyload elements with Lazyload module if available
|
|
187
|
+
if (app?.lazyload?.observe) {
|
|
188
|
+
// Clear data-ll-idx from unloaded [data-ll-image] images
|
|
189
|
+
clone.querySelectorAll('[data-ll-image]:not([data-ll-loaded])').forEach(img => {
|
|
190
|
+
img.removeAttribute('data-ll-idx')
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
// Clear attributes from unloaded [data-ll-srcset] pictures so they can be re-observed
|
|
194
|
+
clone.querySelectorAll('[data-ll-srcset]:not([data-ll-srcset-ready])').forEach(picture => {
|
|
195
|
+
picture.removeAttribute('data-ll-srcset-initialized')
|
|
196
|
+
// Clear ready state from sources and img so they can be re-processed
|
|
197
|
+
picture.querySelectorAll('source').forEach(source => {
|
|
198
|
+
source.removeAttribute('data-ll-ready')
|
|
199
|
+
})
|
|
200
|
+
picture.querySelectorAll('img').forEach(img => {
|
|
201
|
+
img.removeAttribute('data-ll-idx')
|
|
202
|
+
img.removeAttribute('data-ll-loaded')
|
|
203
|
+
img.removeAttribute('data-ll-ready')
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
app.lazyload.observe(clone)
|
|
208
|
+
}
|
|
185
209
|
}
|
|
186
210
|
|
|
187
211
|
// Force layout recalculation
|