Skip to content

Commit e5b58c4

Browse files
committed
Add toggle.
1 parent a5ca39c commit e5b58c4

File tree

7 files changed

+33
-5
lines changed

7 files changed

+33
-5
lines changed

compare.png

2.27 KB
Loading

index.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
</head>
1818

1919
<body>
20-
<div id='map1'>
21-
</div>
22-
<div class='contain clearfix' id='map2'>
23-
</div>
20+
<div id='map1'></div>
21+
<div class='contain clearfix' id='map2'></div>
22+
<div id='toggle' class='leaflet-bar'></div>
2423
<div id='help'>
2524
<a href="https://github.com/lxbarth/compare" class='button' id='forkme'>Fork me on Github</a>
2625
<h2>Compare maps</h2>

site.js

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
if (!layerids) {
44
document.getElementById('map1').style.display = 'none';
55
document.getElementById('map2').style.display = 'none';
6+
document.getElementById('toggle').style.display = 'none';
67
document.getElementById('help').style.display = 'block';
78

89
document.getElementById('compare').onclick = function(e) {
@@ -63,4 +64,9 @@
6364
reset: true
6465
});
6566
}
67+
68+
// Toggle to swipe.
69+
document.getElementById('toggle').onclick = function() {
70+
location.href = location.origin + location.pathname + "swipe/" + location.search + location.hash;
71+
};
6672
})();

style.css

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ body {
77
#map { position:absolute; top:0; bottom:0; width:100%; background-color: #202222; }
88
#map1 { position:absolute; top:0; bottom:0; left:0; right:50%; background-color: #202222; }
99
#map2 { position:absolute; top:0; bottom:0; left:50%; right:0; background-color: #202222; }
10+
#toggle {
11+
position: absolute;
12+
background-image: url('swipe.png');
13+
background-color: rgba(255, 255, 255, 0.5);
14+
z-index: 20000;
15+
top: 10px;
16+
right: 10px;
17+
width: 52px;
18+
height: 26px;
19+
cursor: pointer;
20+
}
1021
#range {
1122
top: 50%;
1223
width: 100%;

swipe.png

2.04 KB
Loading

swipe/index.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
<script src='../common.js'></script>
1616
<link href='https://api.mapbox.com/mapbox.js/v2.2.1/mapbox.css' rel='stylesheet' />
1717
<link href='../style.css' rel='stylesheet' />
18+
<style>
19+
#toggle {
20+
background-image: url('../compare.png');
21+
}
22+
</style>
1823
</head>
1924
<body>
20-
<div id='map'></div>
25+
<div id='map'></div>
26+
<div id='toggle'></div>
2127
<input id="range" type="range" min="0" max="1.0" step="any" style="width: 100%; position: absolute" />
2228
<script src='site.js'></script>
2329
</body>

swipe/site.js

+6
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@
4949
document.getElementById('range').style.top = (e.screenY - 120) + "px";
5050
};
5151
};
52+
53+
// Toggle to compare.
54+
document.getElementById('toggle').onclick = function() {
55+
var path = location.pathname.replace('swipe/', '');
56+
location.href = location.origin + path + location.search + location.hash;
57+
};
5258
})();

0 commit comments

Comments
 (0)