スライドショーをランダムに
This commit is contained in:
parent
f7408f4e82
commit
173ee4bb0e
1 changed files with 3 additions and 6 deletions
|
@ -100,14 +100,12 @@
|
||||||
|
|
||||||
this.change = () => {
|
this.change = () => {
|
||||||
if (this.images.length == 0) return;
|
if (this.images.length == 0) return;
|
||||||
if (this.index >= this.images.length) this.index = 0;
|
|
||||||
|
|
||||||
const img = `url(${ this.images[this.index].url }?thumbnail&size=1024)`;
|
const index = Math.floor(Math.random() * this.images.length);
|
||||||
|
const img = `url(${ this.images[index].url }?thumbnail&size=1024)`;
|
||||||
|
|
||||||
this.refs.slideB.style.backgroundImage = img;
|
this.refs.slideB.style.backgroundImage = img;
|
||||||
|
|
||||||
this.index++;
|
|
||||||
|
|
||||||
anime({
|
anime({
|
||||||
targets: this.refs.slideB,
|
targets: this.refs.slideB,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
|
@ -136,8 +134,7 @@
|
||||||
}).then(images => {
|
}).then(images => {
|
||||||
this.update({
|
this.update({
|
||||||
fetching: false,
|
fetching: false,
|
||||||
images: images,
|
images: images
|
||||||
index: 0
|
|
||||||
});
|
});
|
||||||
this.refs.slideA.style.backgroundImage = '';
|
this.refs.slideA.style.backgroundImage = '';
|
||||||
this.refs.slideB.style.backgroundImage = '';
|
this.refs.slideB.style.backgroundImage = '';
|
||||||
|
|
Loading…
Reference in a new issue