Skip to content

Commit

Permalink
Ability to suppress toolbar (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod authored and jywarren committed Feb 18, 2019
1 parent 649caa4 commit 2e9b358
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dist/leaflet.distortableimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ L.DistortableImage.Edit = L.Handler.extend({
var keymap = this.options.keymap,
handlerName = keymap[event.which];

if (handlerName !== undefined) {
if (handlerName !== undefined && this._overlay.options.suppressToolbar !== true) {
this[handlerName].call(this);
}
},
Expand Down Expand Up @@ -916,8 +916,10 @@ L.DistortableImage.Edit = L.Handler.extend({
else { point = target._leaflet_pos; }
var raised_point = map.containerPointToLatLng(new L.Point(point.x,point.y-20));
raised_point.lng = overlay.getCenter().lng;
if (this._overlay.options.suppressToolbar !== true) {
this.toolbar = new L.DistortableImage.EditToolbar(raised_point).addTo(map, overlay);
overlay.fire('toolbar:created');
}

L.DomEvent.stopPropagation(event);
},
Expand Down
1 change: 1 addition & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
// create an image
img = new L.DistortableImageOverlay(
'example.png', {
suppressToolbar: false,
corners: [
new L.latLng(51.52,-0.10),
new L.latLng(51.52,-0.14),
Expand Down
4 changes: 3 additions & 1 deletion src/edit/DistortableImage.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ L.DistortableImage.Edit = L.Handler.extend({
var keymap = this.options.keymap,
handlerName = keymap[event.which];

if (handlerName !== undefined) {
if (handlerName !== undefined && this._overlay.options.suppressToolbar !== true) {
this[handlerName].call(this);
}
},
Expand Down Expand Up @@ -244,8 +244,10 @@ L.DistortableImage.Edit = L.Handler.extend({
else { point = target._leaflet_pos; }
var raised_point = map.containerPointToLatLng(new L.Point(point.x,point.y-20));
raised_point.lng = overlay.getCenter().lng;
if (this._overlay.options.suppressToolbar !== true) {
this.toolbar = new L.DistortableImage.EditToolbar(raised_point).addTo(map, overlay);
overlay.fire('toolbar:created');
}

L.DomEvent.stopPropagation(event);
},
Expand Down

0 comments on commit 2e9b358

Please sign in to comment.