forked from t4rra/startpage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
67 lines (61 loc) · 2.57 KB
/
script.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
62
63
64
65
66
67
let weather = {
"apiKey": "cf25d4294c96fe4af6a0ace1cd4fc17c",
fetchweather: function (city) {
fetch(
"https://api.openweathermap.org/data/2.5/weather?q=" + city + "&units=metric&appid="+ this.apiKey
)
.then((response) => response.json())
.then((data) => this.displayWeather(data));
},
displayWeather: function (data) {
const { name } = data;
const { icon, description } = data.weather[0];
const { temp, humidity } = data.main;
const { speed } = data.wind;
console.log(name,icon,description,temp,humidity,speed);
document.querySelector(".city").innerText = name;
document.querySelector(".humidity").innerText = "Humidity : " + humidity + "%";
document.querySelector(".windspeed").innerText = "Wind Speed : " + speed + "km/h";
document.querySelector(".Wdescription").innerText = description;
document.querySelector(".icon").src = "http://openweathermap.org/img/wn/" + icon +".png";
document.querySelector(".temp").innerText = "Temperature : " + temp + "°C";
}
}
weather.fetchweather("mostaganem");
const animated = true;
if (animated) {
// hides all elements
document.querySelectorAll("*").forEach(el => el.style.opacity = 0);
// anime.js animation function
function playAnimation() {
var tl = anime.timeline({
easing: "easeInOutExpo",
duration: 2000,
});
tl.add({
targets: "#img",
opacity: [0, 1],
translateY: [100, 0],
})
.add(
{
targets: "#img",
width: ["100%", "60%"],
},
"-=1200"
)
.add(
{
targets: "main *",
opacity: [0, 1],
translateY: [10, 0],
delay: anime.stagger(15),
},
"-=1800"
);
}
window.onload = function () {
document.querySelectorAll("*").forEach(el => el.style.opacity = 1);
playAnimation();
}
}