|
|
@@ -185,7 +185,6 @@ export default {
|
|
185
|
185
|
this.loading = false
|
|
186
|
186
|
},
|
|
187
|
187
|
_setClick(el, cb) {
|
|
188
|
|
- el.dataset.gallery = index
|
|
189
|
188
|
if (el.addEventListener) {
|
|
190
|
189
|
el.addEventListener('click', cb, false)
|
|
191
|
190
|
} else {
|
|
|
@@ -207,12 +206,12 @@ export default {
|
|
207
|
206
|
if (!this.$el) return
|
|
208
|
207
|
const section = this.$el.children[0].querySelector('section')
|
|
209
|
208
|
await nextTick()
|
|
210
|
|
- const galleries = section.querySelectorAll('.wp-block-gallery')
|
|
211
|
|
- galleries.forEach((gallery, galleryIndex) => {
|
|
212
|
|
- gallery.querySelectorAll('img').forEach(image =>
|
|
213
|
|
- this._setClick(image, galleryIndex, e => {
|
|
|
209
|
+ const galleryBlocks = section.querySelectorAll('.wp-block-gallery')
|
|
|
210
|
+ galleryBlocks.forEach((block, blockIndex) => {
|
|
|
211
|
+ block.querySelectorAll('img').forEach(image => {
|
|
|
212
|
+ image.dataset.gallery = blockIndex
|
|
|
213
|
+ this._setClick(image, e => {
|
|
214
|
214
|
this.activeGalleryIndex = e.target.dataset.gallery
|
|
215
|
|
-
|
|
216
|
215
|
const activeGallery =
|
|
217
|
216
|
post.galleries[this.activeGalleryIndex]
|
|
218
|
217
|
|
|
|
@@ -228,8 +227,8 @@ export default {
|
|
228
|
227
|
`opening gallery: ${this.activeGalleryIndex}.${this.activeImageIndex}`,
|
|
229
|
228
|
)
|
|
230
|
229
|
console.log(e.target.dataset)
|
|
231
|
|
- }),
|
|
232
|
|
- )
|
|
|
230
|
+ })
|
|
|
231
|
+ })
|
|
233
|
232
|
})
|
|
234
|
233
|
},
|
|
235
|
234
|
},
|