Skip to content

Commit

Permalink
Merge pull request #797 from wqoq/fix-edit-classname
Browse files Browse the repository at this point in the history
Add/remove className options when PolyVerticesEdit is enabled/disabled
  • Loading branch information
ddproxy committed Oct 20, 2017
2 parents febb0e0 + 35c6b57 commit 7659f8d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/edit/handler/Edit.Poly.js
Expand Up @@ -127,6 +127,7 @@ L.Edit.PolyVerticesEdit = L.Handler.extend({
// Add listener hooks to this handler.
addHooks: function () {
var poly = this._poly;
var path = poly._path;

if (!(poly instanceof L.Polygon)) {
poly.options.fill = false;
Expand All @@ -135,6 +136,19 @@ L.Edit.PolyVerticesEdit = L.Handler.extend({
}
}

if (path) {
if (poly.options.editing.className) {
if (poly.options.original.className) {
poly.options.original.className.split(' ').forEach(function(className) {
L.DomUtil.removeClass(path, className);
});
}
poly.options.editing.className.split(' ').forEach(function(className) {
L.DomUtil.addClass(path, className);
});
}
}

poly.setStyle(poly.options.editing);

if (this._poly._map) {
Expand All @@ -152,6 +166,20 @@ L.Edit.PolyVerticesEdit = L.Handler.extend({
// Remove listener hooks from this handler.
removeHooks: function () {
var poly = this._poly;
var path = poly._path;

if (path) {
if (poly.options.editing.className) {
poly.options.editing.className.split(' ').forEach(function(className) {
L.DomUtil.removeClass(path, className);
});
if (poly.options.original.className) {
poly.options.original.className.split(' ').forEach(function(className) {
L.DomUtil.addClass(path, className);
});
}
}
}

poly.setStyle(poly.options.original);

Expand Down

0 comments on commit 7659f8d

Please sign in to comment.