@brandocms/jupiter 3.48.2 → 3.49.0
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
|
@@ -107,6 +107,10 @@ export default class Application {
|
|
|
107
107
|
left: 0
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
this.state = {
|
|
111
|
+
revealed: false
|
|
112
|
+
}
|
|
113
|
+
|
|
110
114
|
this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
|
|
111
115
|
this.focusableSelectors = this.opts.focusableSelectors
|
|
112
116
|
|
|
@@ -487,6 +491,7 @@ export default class Application {
|
|
|
487
491
|
|
|
488
492
|
_emitRevealedEvent() {
|
|
489
493
|
if (!document.body.hasAttribute('data-app-revealed')) {
|
|
494
|
+
this.state.revealed = true
|
|
490
495
|
document.body.dataset.appRevealed = true
|
|
491
496
|
window.dispatchEvent(this.revealedEvent)
|
|
492
497
|
this.executeCallbacks(Events.APPLICATION_REVEALED)
|
|
@@ -27,9 +27,13 @@ export default class Lazyload {
|
|
|
27
27
|
this.initialize()
|
|
28
28
|
|
|
29
29
|
if (this.opts.registerCallback) {
|
|
30
|
-
this.app.
|
|
30
|
+
if (this.app.state.revealed) {
|
|
31
31
|
this.watch()
|
|
32
|
-
}
|
|
32
|
+
} else {
|
|
33
|
+
this.app.registerCallback(Events.APPLICATION_REVEALED, () => {
|
|
34
|
+
this.watch()
|
|
35
|
+
})
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -73,7 +77,6 @@ export default class Lazyload {
|
|
|
73
77
|
this.opts.revealIntersectionObserverConfig
|
|
74
78
|
)
|
|
75
79
|
|
|
76
|
-
this.lazyPictures = document.querySelectorAll('[data-ll-srcset]')
|
|
77
80
|
this.initObserver(this.loadObserver)
|
|
78
81
|
|
|
79
82
|
// Deprecate data-ll-image sometime
|
|
@@ -94,6 +97,7 @@ export default class Lazyload {
|
|
|
94
97
|
initObserver(observer, setAttrs = true) {
|
|
95
98
|
this.lazyPictures.forEach((picture, idx) => {
|
|
96
99
|
if (setAttrs) {
|
|
100
|
+
picture.setAttribute('data-ll-srcset-initialized', '')
|
|
97
101
|
picture.querySelectorAll('img:not([data-ll-loaded])').forEach(img => {
|
|
98
102
|
img.setAttribute('data-ll-blurred', '')
|
|
99
103
|
img.setAttribute('data-ll-idx', idx)
|
|
@@ -181,11 +185,27 @@ export default class Lazyload {
|
|
|
181
185
|
|
|
182
186
|
// we reveal the picture when it enters the viewport
|
|
183
187
|
handleRevealEntries(elements) {
|
|
188
|
+
const srcsetReadyObserver = new MutationObserver(mutations => {
|
|
189
|
+
mutations.forEach(record => {
|
|
190
|
+
if (record.type === 'attributes' && record.attributeName === 'data-ll-srcset-ready') {
|
|
191
|
+
this.revealPicture(record.target)
|
|
192
|
+
this.revealObserver.unobserve(record.target)
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
|
|
184
197
|
elements.forEach(item => {
|
|
185
198
|
if (item.isIntersecting || item.intersectionRatio > 0) {
|
|
186
199
|
const picture = item.target
|
|
187
|
-
|
|
188
|
-
|
|
200
|
+
const ready = item.target.hasAttribute('data-ll-srcset-ready')
|
|
201
|
+
if (!ready) {
|
|
202
|
+
// element is not loaded, observe the picture and wait for
|
|
203
|
+
// `data-ll-srcset-ready` before revealing
|
|
204
|
+
srcsetReadyObserver.observe(picture, { attributes: true })
|
|
205
|
+
} else {
|
|
206
|
+
this.revealPicture(picture)
|
|
207
|
+
this.revealObserver.unobserve(item.target)
|
|
208
|
+
}
|
|
189
209
|
}
|
|
190
210
|
})
|
|
191
211
|
}
|
|
@@ -8,6 +8,9 @@ const DEFAULT_OPTIONS = {
|
|
|
8
8
|
/* enable captions */
|
|
9
9
|
captions: false,
|
|
10
10
|
|
|
11
|
+
/* enable index numbers */
|
|
12
|
+
numbers: false,
|
|
13
|
+
|
|
11
14
|
/* enable swipe — this breaks native zoom! */
|
|
12
15
|
swipe: true,
|
|
13
16
|
|
|
@@ -73,6 +76,10 @@ const DEFAULT_OPTIONS = {
|
|
|
73
76
|
lightbox.timelines.image.to(lightbox.nextImage, { duration: 0.5, autoAlpha: 1, delay })
|
|
74
77
|
},
|
|
75
78
|
|
|
79
|
+
onNumbers: (lightbox, section) => {
|
|
80
|
+
lightbox.elements.numbers.innerHTML = `${lightbox.currentIndex + 1}/${section.length}`
|
|
81
|
+
},
|
|
82
|
+
|
|
76
83
|
onBeforeOpen: () => {},
|
|
77
84
|
|
|
78
85
|
onOpen: h => {
|
|
@@ -177,6 +184,7 @@ export default class Lightbox {
|
|
|
177
184
|
this.elements.content = document.createElement('div')
|
|
178
185
|
this.elements.imgWrapper = document.createElement('div')
|
|
179
186
|
this.elements.dots = document.createElement('div')
|
|
187
|
+
this.elements.numbers = document.createElement('div')
|
|
180
188
|
this.elements.nextArrow = document.createElement('a')
|
|
181
189
|
this.elements.prevArrow = document.createElement('a')
|
|
182
190
|
this.elements.close = document.createElement('a')
|
|
@@ -188,6 +196,7 @@ export default class Lightbox {
|
|
|
188
196
|
this.elements.prevArrow.classList.add('lightbox-prev')
|
|
189
197
|
this.elements.close.classList.add('lightbox-close')
|
|
190
198
|
this.elements.dots.classList.add('lightbox-dots')
|
|
199
|
+
this.elements.numbers.classList.add('lightbox-numbers')
|
|
191
200
|
this.elements.wrapper.classList.add('lightbox-backdrop')
|
|
192
201
|
this.elements.wrapper.setAttribute('data-lightbox-wrapper-section', section)
|
|
193
202
|
this.elements.imgWrapper.classList.add('lightbox-image-wrapper')
|
|
@@ -210,9 +219,12 @@ export default class Lightbox {
|
|
|
210
219
|
this.setImg(section, this.getPrevIdx(section))
|
|
211
220
|
})
|
|
212
221
|
|
|
213
|
-
|
|
222
|
+
this.keyUpCallback = event => {
|
|
214
223
|
this.onKeyup(event, section)
|
|
215
|
-
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
document.removeEventListener('keyup', this.keyUpCallback)
|
|
227
|
+
document.addEventListener('keyup', this.keyUpCallback)
|
|
216
228
|
|
|
217
229
|
this.elements.wrapper.addEventListener('mousemove', event => {
|
|
218
230
|
this.onMouseMove(event)
|
|
@@ -264,6 +276,10 @@ export default class Lightbox {
|
|
|
264
276
|
this.elements.content.appendChild(this.elements.prevArrow)
|
|
265
277
|
this.elements.content.appendChild(this.elements.dots)
|
|
266
278
|
|
|
279
|
+
if (this.opts.numbers) {
|
|
280
|
+
this.elements.content.appendChild(this.elements.numbers)
|
|
281
|
+
}
|
|
282
|
+
|
|
267
283
|
if (this.opts.captions) {
|
|
268
284
|
this.elements.caption = document.createElement('div')
|
|
269
285
|
this.elements.caption.classList.add('lightbox-caption')
|
|
@@ -273,7 +289,7 @@ export default class Lightbox {
|
|
|
273
289
|
this.elements.wrapper.appendChild(this.elements.content)
|
|
274
290
|
document.body.appendChild(this.elements.wrapper)
|
|
275
291
|
|
|
276
|
-
this.setImg(section, index, this.getPrevIdx(
|
|
292
|
+
this.setImg(section, index, this.getPrevIdx(section))
|
|
277
293
|
if (this.opts.swipe) {
|
|
278
294
|
this.attachSwiper(section, this.elements.content, index)
|
|
279
295
|
}
|
|
@@ -289,7 +305,7 @@ export default class Lightbox {
|
|
|
289
305
|
}
|
|
290
306
|
|
|
291
307
|
close() {
|
|
292
|
-
document.removeEventListener('keyup', this.
|
|
308
|
+
document.removeEventListener('keyup', this.keyUpCallback)
|
|
293
309
|
this.opts.onClose(this)
|
|
294
310
|
this.opts.onAfterClose(this)
|
|
295
311
|
this.currentIndex = null
|
|
@@ -326,6 +342,10 @@ export default class Lightbox {
|
|
|
326
342
|
})
|
|
327
343
|
}
|
|
328
344
|
|
|
345
|
+
if (this.elements.numbers) {
|
|
346
|
+
this.opts.onNumbers(this, this.sections[section])
|
|
347
|
+
}
|
|
348
|
+
|
|
329
349
|
if (this.currentImage) {
|
|
330
350
|
// fade out current image
|
|
331
351
|
this.opts.onImageOut(this)
|