Skip to content

Commit

Permalink
Show throbber/spinner during suggest attempt
Browse files Browse the repository at this point in the history
This close #242
  • Loading branch information
keul authored and simon04 committed Jun 4, 2019
1 parent 7cf3385 commit ceeb796
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export var Geocoder = L.Control.extend({
this._requestCount = 0;
},

addThrobberClass: function() {
L.DomUtil.addClass(this._container, 'leaflet-control-geocoder-throbber');
},

removeThrobberClass: function() {
L.DomUtil.removeClass(this._container, 'leaflet-control-geocoder-throbber');
},

onAdd: function(map) {
var className = 'leaflet-control-geocoder',
container = L.DomUtil.create('div', className + ' leaflet-bar'),
Expand Down Expand Up @@ -125,20 +133,10 @@ export var Geocoder = L.Control.extend({
this.on('markgeocode', this.markGeocode, this);
}

this.on(
'startgeocode',
function() {
L.DomUtil.addClass(this._container, 'leaflet-control-geocoder-throbber');
},
this
);
this.on(
'finishgeocode',
function() {
L.DomUtil.removeClass(this._container, 'leaflet-control-geocoder-throbber');
},
this
);
this.on('startgeocode', this.addThrobberClass, this);
this.on('finishgeocode', this.removeThrobberClass, this);
this.on('startsuggest', this.addThrobberClass, this);
this.on('finishsuggest', this.removeThrobberClass, this);

L.DomEvent.disableClickPropagation(container);

Expand Down

0 comments on commit ceeb796

Please sign in to comment.