<commit_before>/*
 * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
 */

L.Handler.MarkerDrag = L.Handler.extend({
	initialize: function(marker) {
		this._marker = marker;
	},
	
	enable: function() {
		if (this._enabled) { return; }
		if (!this._draggable) {
			this._draggable = new L.Draggable(this._marker._icon, this._marker._icon);
			this._draggable.on('dragstart', this._onDragStart, this);
			this._draggable.on('drag', this._onDrag, this);
			this._draggable.on('dragend', this._onDragEnd, this);
		}
		this._draggable.enable();
		this._enabled = true;
	},
	
	disable: function() {
		if (!this._enabled) { return; }
		this._draggable.disable();
		this._enabled = false;
	},
	
	moved: function() {
		return this._draggable && this._draggable._moved;
	},
	
	_onDragStart: function(e) {
		this._marker.closePopup();
		
		this._marker.fire('movestart');
		this._marker.fire('dragstart');
	},
	
	_onDrag: function(e) {
		// update shadow position
		var iconPos = L.DomUtil.getPosition(this._marker._icon);
		L.DomUtil.setPosition(this._marker._shadow, iconPos);
		
		this._marker._latlng = this._marker._map.layerPointToLatLng(iconPos);
	
		this._marker.fire('move');
		this._marker.fire('drag');
	},
	
	_onDragEnd: function() {
		this._marker.fire('moveend');
		this._marker.fire('dragend');
	}
});<commit_msg>Fix dragging markers without shadows<commit_after>/*
 * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
 */

L.Handler.MarkerDrag = L.Handler.extend({
	initialize: function(marker) {
		this._marker = marker;
	},
	
	enable: function() {
		if (this._enabled) { return; }
		if (!this._draggable) {
			this._draggable = new L.Draggable(this._marker._icon, this._marker._icon);
			this._draggable.on('dragstart', this._onDragStart, this);
			this._draggable.on('drag', this._onDrag, this);
			this._draggable.on('dragend', this._onDragEnd, this);
		}
		this._draggable.enable();
		this._enabled = true;
	},
	
	disable: function() {
		if (!this._enabled) { return; }
		this._draggable.disable();
		this._enabled = false;
	},
	
	moved: function() {
		return this._draggable && this._draggable._moved;
	},
	
	_onDragStart: function(e) {
		this._marker.closePopup();
		
		this._marker.fire('movestart');
		this._marker.fire('dragstart');
	},
	
	_onDrag: function(e) {
		// update shadow position
		var iconPos = L.DomUtil.getPosition(this._marker._icon);
		if (this._marker._shadow) L.DomUtil.setPosition(this._marker._shadow, iconPos);
		
		this._marker._latlng = this._marker._map.layerPointToLatLng(iconPos);
	
		this._marker.fire('move');
		this._marker.fire('drag');
	},
	
	_onDragEnd: function() {
		this._marker.fire('moveend');
		this._marker.fire('dragend');
	}
});
{'fraction_non_alphanumeric': 0.1628498727735369, 'fraction_numerical': 0.0, 'mean_word_length': 4.086876155268023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '741644', 'n_tokens_mistral': 1055, 'n_tokens_neox': 954, 'n_words': 160}