-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapscript.js
81 lines (72 loc) · 1.88 KB
/
mapscript.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var countryData = "";
var activeCountry = "";
var timestamp = 0;
var mY = 0;
function getData() {
$.ajax({
url: 'https://coronavirus-19-api.herokuapp.com/countries',
type: 'GET',
success: function(response) {
countryData = $(response);
appendData();
}
});
}
getData();
function appendData(){
for (var i = 0 ; i < countryData.length ; i++) {
$("#tooltip").append("<div data-name='"+countryData[i].country+"' class='data'><h3>"+countryData[i].country+"</h3><h4>Total Cases:<span> "+countryData[i].cases+"</span></h4><h4>Total Deaths:<span> "+countryData[i].deaths+"</span></h4><h4>Total Recoveries:<span> "+countryData[i].recovered+"</span></h4></div>");
};
$('#lower path').hover(function(){
$('#tooltip').toggleClass('active');
activeCountry = $(this).attr("data-name");
$(this).toggleClass('active');
$('.data').removeClass('active');
$('.data[data-name="'+ activeCountry +'"]').addClass('active');
})
setTimeout(function(){
$('body').addClass('loaded');
}, 2000);
}
var $self = $('#map'),
$cursor = $("#tooltip"),
$country = $("svg path"),
$map = $("#map #lower");
$country.mouseover(function(){
gsap.to(this, {
duration: 0.2,
scale: 1.05,
transformOrigin: '50% 50%',
overwrite: true
});
});
$country.mouseout(function(){
gsap.to(this, {
duration: 0.2,
scale: 1,
overwrite: true
});
});
$self.mousemove(function(e) {
gsap.to($map, {
left: (e.pageX * -1),
top: (e.pageY * -1) + 150,
duration: 0.2,
scale: 1,
overwrite: true
});
gsap.to($cursor, {
left: e.pageX - 125,
top: e.pageY - 175,
duration: 0.2,
overwrite: true
});
});
$self.mouseout(function() {
gsap.to($map, {
duration: 1,
left: '-50vw',
top: '-25vh',
overwrite: true
});
});