-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
57 lines (48 loc) · 1.67 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
$(function() {
//wait for carto to finish loading
setTimeout(function() {
$('.legend').show();
}, 3000);
// set up listener for show legend button and show the legend when clicked
$('.showLegend').click(function() {
$('.legend').show();
$('.showLegend').hide();
});
$('.hideLegend').click(function() {
$('.legend').hide();
$('.showLegend').show();
});
// scroll legend to the right wehn right chevron is clicked
var scrollPixels = 430;
$(".chevron-right-fade").click(function(e){
var leftPos = $('.legend').scrollLeft();
$('.legend').animate({scrollLeft: leftPos + scrollPixels }, 800);
});
// change color of chevronon hover
$(".chevron-right-fade").hover(function(e){
$('.chevron-right-wrapper').toggleClass('hover');
});
// scroll legend to the left when left chevron is clicked
$(".chevron-left-fade").click(function(e){
var leftPos = $('.legend').scrollLeft();
$('.legend').animate({scrollLeft: leftPos - scrollPixels }, 800);
});
// change color of chevronon hover
$(".chevron-left-fade").hover(function(e){
$('.chevron-left-wrapper').toggleClass('hover');
});
// listen for scrolling
$('.legend').scroll(function() {
var leftPos = $('.legend').scrollLeft();
if (leftPos <= 0) {
$(".chevron-left-fade").hide();
} else {
$(".chevron-left-fade").show();
}
if ($('.legendSVG').width() < (leftPos + $('.legend').width())) {
$(".chevron-right-fade").hide();
} else {
$(".chevron-right-fade").show();
}
});
});