-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslider1.js
48 lines (37 loc) · 1.43 KB
/
slider1.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
const main = document.getElementById('main');
const sliderImg = document.getElementById("innerDiv2Img");
var time = 7000;
var x = window.matchMedia("(max-width: 600px)")
myFunction(x)
function myFunction(x) {
if (x.matches) { // If media query matches
animationArray = [
"slideVertically 6.9s ease-in-out infinite",
"slideVerticallyInverse 6.9s ease-in-out infinite",
"slideHorizontally 6.8s ease-in-out infinite",
"slideHorizontallyInverse 6.8s ease-in-out infinite"
];
} else {
animationArray = [
"slideVertically 6.6s ease-in-out infinite",
"slideVerticallyInverse 6.6s ease-in-out infinite",
"slideHorizontally 6.8s ease-in-out infinite",
"slideHorizontallyInverse 6.8s ease-in-out infinite"
];
}
}
sfw = ["waifu","neko","shinobu","megumin","bully","cuddle","cry","hug","awoo","kiss","lick","smug","bonk","yeet","blush","smile","wave","highfive","handhold"]
function changeImg(imgLink){
randomWord = sfw[Math.floor(Math.random() * sfw.length)]
image = `https://api.waifu.pics/sfw/${randomWord}`;
fetch(image)
.then(res=>res.json())
.then(data=>{
sliderImg.src = data.url;
})
sliderImg.style.animation = `${
animationArray[Math.floor(Math.random() * animationArray.length)]
}`;
setTimeout("changeImg()", time);
}
changeImg()