|
|
|
@ -4,7 +4,7 @@ const rightBtn = document.getElementById('right')
|
|
|
|
|
|
|
|
|
|
const img = document.querySelectorAll('#imgs img')
|
|
|
|
|
|
|
|
|
|
let idx = 0
|
|
|
|
|
let idx = 1
|
|
|
|
|
|
|
|
|
|
let interval = setInterval(run, 2000)
|
|
|
|
|
|
|
|
|
@ -15,12 +15,34 @@ function run() {
|
|
|
|
|
|
|
|
|
|
function changeImage() {
|
|
|
|
|
if(idx > img.length - 1) {
|
|
|
|
|
idx = 0
|
|
|
|
|
} else if(idx < 0) {
|
|
|
|
|
idx = img.length - 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
imgs.style.transform = `translateX(${-idx * 500}px)`
|
|
|
|
|
imgs.style.transition = 'all, linear, 1s';
|
|
|
|
|
imgs.style.transform = `translateX(${-idx * 500}px)`
|
|
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
idx = 1;
|
|
|
|
|
imgs.style.transition = '';
|
|
|
|
|
imgs.style.transform = `translateX(${-500}px)`
|
|
|
|
|
},0)
|
|
|
|
|
}
|
|
|
|
|
else if(idx < 0){
|
|
|
|
|
idx = 0
|
|
|
|
|
|
|
|
|
|
imgs.style.transition = 'all, linear, 1s';
|
|
|
|
|
imgs.style.transform = `translateX(${-idx * 500}px)`
|
|
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
idx = img.length - 2;
|
|
|
|
|
imgs.style.transition = '';
|
|
|
|
|
imgs.style.transform = `translateX(${-idx * 500}px)`
|
|
|
|
|
},0)
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
imgs.style.transition = 'all, linear, 1s';
|
|
|
|
|
imgs.style.transform = `translateX(${-idx * 500}px)`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resetInterval() {
|
|
|
|
|