Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
mblomdahl committed Dec 3, 2017
1 parent 553b220 commit 7a3eea6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1159,17 +1159,17 @@ class MapboxCircle {

map.on('styledataloading', this._onMapStyleDataLoading);

let target = map.getContainer();
this.observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
let removedNodes = Array.from(mutation.removedNodes);
let directMatch = removedNodes.indexOf(target) > -1;
let parentMatch = removedNodes.some(parent => parent.contains(target));
const target = map.getContainer();
this.observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
const removedNodes = Array.from(mutation.removedNodes);
const directMatch = removedNodes.indexOf(target) > -1;
const parentMatch = removedNodes.some((parent) => parent.contains(target));
if (directMatch || parentMatch) {
this.remove();
}
}.bind(this));
}.bind(this));
});
});

let config = {
subtree: true,
Expand Down Expand Up @@ -1202,6 +1202,7 @@ class MapboxCircle {
*/
remove() {
this.map.off('styledataloading', this._onMapStyleDataLoading);

this.observer.disconnect();

if (this.options.editable) {
Expand Down

0 comments on commit 7a3eea6

Please sign in to comment.