double click zoom (initial)
This commit is contained in:
parent
e734e20d55
commit
56c6a8c20f
@ -33,10 +33,11 @@
|
||||
<script type="text/javascript" src="../src/handler/Handler.js"></script>
|
||||
<script type="text/javascript" src="../src/handler/MapDrag.js"></script>
|
||||
<script type="text/javascript" src="../src/handler/TouchZoom.js"></script>
|
||||
<script type="text/javascript" src="../src/handler/DoubleClickZoom.js"></script>
|
||||
|
||||
<!-- /map -->
|
||||
<script type="text/javascript" src="../src/map/Map.js"></script>
|
||||
<script type="text/javascript" src="../src/map/MapGeolocationExt.js"></script>
|
||||
<script type="text/javascript" src="../src/map/Map.Geolocation.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../dist/leaflet.css" />
|
||||
|
||||
|
@ -30,10 +30,12 @@
|
||||
<!-- /handlers -->
|
||||
<script type="text/javascript" src="../src/handler/Handler.js"></script>
|
||||
<script type="text/javascript" src="../src/handler/MapDrag.js"></script>
|
||||
<script type="text/javascript" src="../src/handler/TouchZoom.js"></script>
|
||||
<script type="text/javascript" src="../src/handler/DoubleClickZoom.js"></script>
|
||||
|
||||
<!-- /map -->
|
||||
<script type="text/javascript" src="../src/map/Map.js"></script>
|
||||
<script type="text/javascript" src="../src/map/MapGeolocationExt.js"></script>
|
||||
<script type="text/javascript" src="../src/map/Map.Geolocation.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../dist/leaflet.css" />
|
||||
</head>
|
||||
|
40
src/handler/DoubleClickZoom.js
Normal file
40
src/handler/DoubleClickZoom.js
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* L.Handler.DoubleClickZoom is used internally by L.Map to add double-click zooming.
|
||||
*/
|
||||
|
||||
L.Handler.DoubleClickZoom = L.Handler.extend({
|
||||
statics: {
|
||||
DOUBLE_TAP_DELAY: 500
|
||||
},
|
||||
|
||||
enable: function() {
|
||||
if (this._enabled) { return; }
|
||||
L.DomEvent.addListener(this._map._container,
|
||||
L.Browser.mobileWebkit ? 'click' : 'dblclick',
|
||||
L.Browser.mobileWebkit ? this._onMobileWebkitClick : this._onDoubleClick,
|
||||
this);
|
||||
this._enabled = true;
|
||||
},
|
||||
|
||||
disable: function() {
|
||||
if (!this._enabled) { return; }
|
||||
L.DomEvent.removeListener(this._map._container,
|
||||
L.Browser.mobileWebkit ? 'click' : 'dblclick',
|
||||
L.Browser.mobileWebkit ? this._onMobileWebkitClick : this._onDoubleClick);
|
||||
this._enabled = false;
|
||||
},
|
||||
|
||||
_onDoubleClick: function(e) {
|
||||
this._map.setView(this._map.mouseEventToLatLng(e), this._map._zoom + 1);
|
||||
},
|
||||
|
||||
_onMobileWebkitClick: function(e) {
|
||||
console.log('click');
|
||||
var time = new Date(),
|
||||
delay = L.Handler.DoubleClickZoom.DOUBLE_TAP_DELAY;
|
||||
if (this._lastClickTime && (time - this._lastClickTime < delay)) {
|
||||
this._onDoubleClick.call(this._map, e);
|
||||
}
|
||||
this._lastClickTime = time;
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user