Skip to content

Commit

Permalink
Merge pull request #10 from Andrew-SK/fix-draggable-marker-rotation
Browse files Browse the repository at this point in the history
Apply rotation transformation on marker drag.
  • Loading branch information
bbecquet authored Nov 11, 2016
2 parents 56f1f4e + 209d64b commit fabdae0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions leaflet.rotatedMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// save these original methods before they are overwritten
var proto_initIcon = L.Marker.prototype._initIcon;
var proto_setPos = L.Marker.prototype._setPos;
var proto_onDrag = L.Handler.MarkerDrag.prototype._onDrag;

var oldIE = (L.DomUtil.TRANSFORM === 'msTransform');

Expand All @@ -22,7 +23,10 @@

_setPos: function (pos) {
proto_setPos.call(this, pos);
this._applyRotation();
},

_applyRotation: function () {
if(this.options.rotationAngle) {
this._icon.style[L.DomUtil.TRANSFORM+'Origin'] = this.options.rotationOrigin;

Expand All @@ -48,4 +52,11 @@
return this;
}
});

L.Handler.MarkerDrag.include({
_onDrag: function (e) {
proto_onDrag.call(this, e);
this._marker._applyRotation();
}
})
})();

0 comments on commit fabdae0

Please sign in to comment.