Skip to content

Commit cec5f78

Browse files
authored
Merge pull request #23 from pexea12/fix-watched-images
Fix watched images
2 parents ce9527c + 11b2d06 commit cec5f78

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

dist/vue-image-lightbox.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-image-lightbox.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-image-lightbox",
33
"description": "A Vue.js package to display an image gallery lightbox",
4-
"version": "5.5.1",
4+
"version": "5.5.2",
55
"author": "Nguyen Thien Dzung <[email protected]>",
66
"license": "MIT",
77
"main": "dist/vue-image-lightbox.min.js",

src/components/script.js

+20-9
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export default {
5353
select: this.startAt,
5454
thumbSelect: this.startAt,
5555
lightBoxOn: this.showLightBox,
56-
countImages: this.images.length,
5756
displayThumbs: this.images.slice(0, this.nThumbs),
5857
timer: null,
5958

@@ -62,6 +61,10 @@ export default {
6261
},
6362

6463
computed: {
64+
countImages() {
65+
return this.images.length
66+
},
67+
6568
imagesThumb() {
6669
if (this.siteLoading) {
6770
return this.displayThumbs.map(({ thumb }) => ({
@@ -75,16 +78,16 @@ export default {
7578
},
7679
},
7780

78-
mounted() {
79-
if (this.autoPlay) {
80-
this.timer = setInterval(() => {
81-
this.nextImage()
82-
}, this.autoPlayTime)
83-
}
84-
},
81+
watch: {
82+
startAt() {
83+
this.$set(this, 'select', this.startAt)
84+
this.$set(this, 'thumbSelect', this.startAt)
85+
},
8586

87+
images() {
88+
this.$set(this, 'displayThumbs', this.images.slice(0, this.nThumbs))
89+
},
8690

87-
watch: {
8891
select() {
8992
let halfDown = Math.floor(this.nThumbs / 2)
9093
let mod = 1 - (this.nThumbs % 2)
@@ -119,6 +122,14 @@ export default {
119122
},
120123
},
121124

125+
mounted() {
126+
if (this.autoPlay) {
127+
this.timer = setInterval(() => {
128+
this.nextImage()
129+
}, this.autoPlayTime)
130+
}
131+
},
132+
122133
methods: {
123134
showImage(index) {
124135
document.addEventListener('keydown', this.addKeyEvent)

0 commit comments

Comments
 (0)