|
|
@@ -1,6 +1,6 @@
|
|
1
|
1
|
<template lang="pug">
|
|
2
|
2
|
.page--single.f-row.between(v-if="$route.params.slug")
|
|
3
|
|
- gallery(:fullscreengallery="fullscreengallery" v-on:close="fullscreengallery = false" :images="images")
|
|
|
3
|
+ gallery(:fullscreengallery="fullscreengallery" v-on:close="fullscreengallery = false" :images="images" :startwith="lastImageClicked")
|
|
4
|
4
|
article.f-grow.shadow
|
|
5
|
5
|
header
|
|
6
|
6
|
h1 {{ type }}:{{ $route.params.slug }} single
|
|
|
@@ -33,7 +33,8 @@ export default {
|
|
33
|
33
|
data() {
|
|
34
|
34
|
return {
|
|
35
|
35
|
images: [],
|
|
36
|
|
- fullscreengallery: false
|
|
|
36
|
+ fullscreengallery: false,
|
|
|
37
|
+ lastImageClicked: 0
|
|
37
|
38
|
}
|
|
38
|
39
|
},
|
|
39
|
40
|
computed: {
|
|
|
@@ -72,18 +73,30 @@ export default {
|
|
72
|
73
|
if(!block) return
|
|
73
|
74
|
const doc = new DOMParser().parseFromString(block, 'text/html')
|
|
74
|
75
|
const gallery = doc.querySelectorAll('.blocks-gallery-item img')
|
|
|
76
|
+ // add captions
|
|
75
|
77
|
if(gallery) {
|
|
76
|
78
|
this.images = [].slice.call(gallery).map(
|
|
77
|
|
- item => { return item.src }
|
|
|
79
|
+ item => { return item.src }
|
|
78
|
80
|
)
|
|
79
|
81
|
}
|
|
80
|
82
|
})
|
|
|
83
|
+ },
|
|
|
84
|
+ wrapImagesWithLink() {
|
|
|
85
|
+ const gallery = document.querySelectorAll('.blocks-gallery-item figure, figure.wp-block-image')
|
|
|
86
|
+ gallery.forEach((item, i) => {
|
|
|
87
|
+ item.addEventListener('click', () => {
|
|
|
88
|
+ this.lastImageClicked = i
|
|
|
89
|
+ console.log('yeah!', this.lastImageClicked)
|
|
|
90
|
+ this.fullscreengallery = true
|
|
|
91
|
+ })
|
|
|
92
|
+ })
|
|
81
|
93
|
}
|
|
82
|
94
|
},
|
|
83
|
95
|
watch: {
|
|
84
|
96
|
posts(newVal, oldVal) {
|
|
85
|
97
|
// Loads images from the DOM
|
|
86
|
98
|
this.checkForImages(newVal)
|
|
|
99
|
+ this.wrapImagesWithLink()
|
|
87
|
100
|
}
|
|
88
|
101
|
},
|
|
89
|
102
|
mounted() {
|