mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-24 17:47:40 +01:00
Add animations to customMarkers
This commit is contained in:
parent
e0b9e6bfe7
commit
55bcffe92a
@ -37,6 +37,9 @@ L.CustomMarker = L.Class.extend({
|
||||
|
||||
map.on('viewreset', this._reset, this);
|
||||
this._reset();
|
||||
if (map.options.zoomAnimation && map.options.markerZoomAnimation) {
|
||||
map.on('zoomanim', this._animateZoom, this);
|
||||
}
|
||||
},
|
||||
|
||||
onRemove: function(map) {
|
||||
@ -60,6 +63,12 @@ L.CustomMarker = L.Class.extend({
|
||||
this._latlng = latlng;
|
||||
this._reset();
|
||||
},
|
||||
|
||||
_animateZoom: function (opt) {
|
||||
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center);
|
||||
L.DomUtil.setPosition(this._element, pos);
|
||||
this._element.style.zIndex = pos.y;
|
||||
},
|
||||
|
||||
_reset: function() {
|
||||
if(this._map == null)
|
||||
@ -97,6 +106,9 @@ L.CustomMarker = L.Class.extend({
|
||||
this.dragging.enable();
|
||||
}
|
||||
}
|
||||
var animation = (map.options.zoomAnimation && map.options.markerZoomAnimation);
|
||||
if (this._element)
|
||||
this._element.className += animation ? ' leaflet-zoom-animated' : ' leaflet-zoom-hide';
|
||||
},
|
||||
|
||||
_onMouseClick: function(e) {
|
||||
@ -131,4 +143,4 @@ L.CustomMarker = L.Class.extend({
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user