-
Notifications
You must be signed in to change notification settings - Fork 4
/
cara1.js
61 lines (51 loc) · 1.21 KB
/
cara1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const slides = document.querySelectorAll(".slide");
const first =document.querySelector(".one");
const five =document.querySelector(".five");
const third =document.querySelector(".third");
console.log(slides);
var counter =0;
// slides.forEach((slide,index) => {
// slide.style.left=`${index*50}%`
// });
const slideImage =() => {
slides.forEach(slide => {
if(counter==4){
first.style.transform =`translateX(+100%)`
five.style.transform =`translateX(-400%)`
}
else if(counter==0){
first.style.transform =`translateX(0%)`
third.style.transform =`translateX(-100%)`
}
else{
slide.style.transform =`translateX(-${counter*100}%)`
}
});
}
// const slideImageN =() => {
// slides.forEach(slide => {
// slide.style.transform =`translateX(-${0*100}%)`
// });
// }
const goPrev=()=>{
if(counter==0)
{
counter+=3;
slideImage();
}
else{
counter--;
slideImage();
}
}
const goNext=()=>{
if(counter==4){
slideImage();
counter=counter-4;
}
else{
counter++;
slideImage();
}
console.log(counter);
}