Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit 708753d

Browse files
committed
Branching 'dist' files for release
1 parent ab9faa6 commit 708753d

File tree

3 files changed

+168
-1
lines changed

3 files changed

+168
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ build/Release
2626
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2727
node_modules
2828

29-
dist/
29+
dist/*.zip
3030

3131
.gobble-build/
3232
.gobble-watch/

dist/L.VisualClick.css

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Heavily based on the CSS for https://github.com/mapshakers/leaflet-icon-pulse
3+
*
4+
* Modified to get rid of the opaque circle, and tweaked the pulse to be subtler.
5+
*/
6+
7+
.leaflet-visualclick-icon {
8+
border-radius: 100%;
9+
}
10+
11+
.leaflet-visualclick-icon:after {
12+
content: "";
13+
border-radius: 100%;
14+
height: 60px;
15+
width: 60px;
16+
position: absolute;
17+
margin-left: -30px;
18+
margin-top: -30px;
19+
20+
box-shadow: inset 0 0 25px -1px #E1E3E4, 0 0 10px -1px #C5C5C5;
21+
22+
-webkit-animation: visualclick-pulsate 0.7s ease-out;
23+
24+
animation: visualclick-pulsate 0.7s ease-out;
25+
-webkit-animation-iteration-count: 1;
26+
animation-iteration-count: 1;
27+
-webkit-animation-delay: 0s;
28+
animation-delay: 0s;
29+
opacity: 0;
30+
}
31+
32+
.leaflet-visualclick-icon-touch:after {
33+
content: "";
34+
border-radius: 100%;
35+
height: 140px;
36+
width: 140px;
37+
position: absolute;
38+
margin-left: -70px;
39+
margin-top: -70px;
40+
41+
box-shadow: inset 0 0 25px -1px #E1E3E4, 0 0 10px -1px #C5C5C5;
42+
43+
-webkit-animation: visualclick-pulsate-touch 0.7s ease-out;
44+
45+
animation: visualclick-pulsate-touch 0.7s ease-out;
46+
-webkit-animation-iteration-count: 1;
47+
animation-iteration-count: 1;
48+
-webkit-animation-delay: 0s;
49+
animation-delay: 0s;
50+
opacity: 0;
51+
}
52+
53+
@-webkit-keyframes visualclick-pulsate {
54+
0% {
55+
-webkit-transform: scale(0.5);
56+
transform: scale(0.5);
57+
opacity: 1;
58+
}
59+
100% {
60+
-webkit-transform: scale(1.3);
61+
transform: scale(1.3);
62+
opacity: 0;
63+
}
64+
}
65+
66+
@keyframes visualclick-pulsate {
67+
0% {
68+
-webkit-transform: scale(0.5);
69+
transform: scale(0.5);
70+
opacity: 1;
71+
}
72+
100% {
73+
-webkit-transform: scale(1.3);
74+
transform: scale(1.3);
75+
opacity: 0;
76+
}
77+
}
78+
79+
80+
@-webkit-keyframes visualclick-pulsate-touch {
81+
from {
82+
-webkit-transform: scale(1);
83+
transform: scale(1);
84+
opacity: 0.8;
85+
}
86+
to {
87+
-webkit-transform: scale(0.2);
88+
transform: scale(0.2);
89+
opacity: 0.0;
90+
}
91+
}
92+
93+
94+
@keyframes visualclick-pulsate-touch {
95+
from {
96+
-webkit-transform: scale(1);
97+
transform: scale(1);
98+
opacity: 0.8;
99+
}
100+
to {
101+
-webkit-transform: scale(0.2);
102+
transform: scale(0.2);
103+
opacity: 0.0;
104+
}
105+
}

dist/L.VisualClick.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* L.VisualClick
3+
* Description: A plugin that adds visual feedback when user clicks/taps the map. Useful for when you have a delay on the clickEvents for async fetching of data, or implmentation of Leaflet.singleclick
4+
* Example: L.visualClick({map: leafletMap}); //Just works
5+
* Author: Dag Jomar Mersland (twitter: @dagjomar)
6+
*/
7+
8+
9+
L.Map.VisualClick = L.Handler.extend({
10+
11+
_makeVisualIcon: function(){
12+
13+
var touchMode = this._map.options.visualClickMode === 'touch' ? true : false;
14+
15+
return L.divIcon({
16+
className: "leaflet-visualclick-icon" + (touchMode ? '-touch' : ''), // See L.VisualClick.css
17+
iconSize: [0, 0],
18+
clickable: false
19+
});
20+
21+
},
22+
23+
_visualIcon: null,
24+
25+
_onClick: function(e) {
26+
27+
var map = this._map;
28+
29+
var latlng = e.latlng;
30+
var marker = L.marker(latlng, {pane: 'shadowPane', icon: this._visualIcon, interactive: false}).addTo(map);
31+
32+
window.setTimeout(function(){
33+
if(map){
34+
marker.remove();
35+
}
36+
}.bind(this), map.options.visualClick.removeTimeout || 450); // Should somewhat match the css animation to prevent loops
37+
38+
return true;
39+
},
40+
41+
addHooks: function () {
42+
if(this._visualIcon === null){
43+
this._visualIcon = this._makeVisualIcon();
44+
}
45+
this._map.on(this._map.options.visualClickEvents, this._onClick, this);
46+
},
47+
48+
removeHooks: function () {
49+
this._map.off(this._map.options.visualClickEvents, this._onClick, this);
50+
},
51+
52+
});
53+
54+
55+
L.Map.mergeOptions({
56+
visualClick: L.Browser.any3d ? true : false, //Can be true, desktop, touch, false. Not straight forward to use L.Browser.touch flag because true on IE10
57+
visualClickMode: L.Browser.touch && L.Browser.mobile ? 'touch' : 'desktop', //Not straight forward to use only L.Browser.touch flag because true on IE10 - so this is slightly better
58+
visualClickEvents: 'click contextmenu', //Standard leaflety way of defining which events to hook on to
59+
});
60+
61+
L.Map.addInitHook('addHandler', 'visualClick', L.Map.VisualClick);
62+

0 commit comments

Comments
 (0)