Add/remove active class on map UI buttons
This commit is contained in:
parent
a125ee829a
commit
fa9b4a5f6a
5 changed files with 20 additions and 12 deletions
|
@ -2,6 +2,7 @@ L.OSM.sidebar = function(selector) {
|
|||
var control = {},
|
||||
sidebar = $(selector),
|
||||
current = $(),
|
||||
currentButton = $(),
|
||||
map;
|
||||
|
||||
control.addTo = function (_) {
|
||||
|
@ -15,17 +16,21 @@ L.OSM.sidebar = function(selector) {
|
|||
.appendTo(sidebar);
|
||||
};
|
||||
|
||||
control.togglePane = function(pane) {
|
||||
control.togglePane = function(pane, button) {
|
||||
current
|
||||
.hide()
|
||||
.trigger('hide');
|
||||
|
||||
currentButton
|
||||
.removeClass('active');
|
||||
|
||||
if (current === pane) {
|
||||
$(sidebar).hide();
|
||||
current = $();
|
||||
current = currentButton = $();
|
||||
} else {
|
||||
$(sidebar).show();
|
||||
current = pane;
|
||||
currentButton = button || $();
|
||||
}
|
||||
|
||||
map.invalidateSize({pan: false, animate: false});
|
||||
|
@ -33,6 +38,9 @@ L.OSM.sidebar = function(selector) {
|
|||
current
|
||||
.show()
|
||||
.trigger('show');
|
||||
|
||||
currentButton
|
||||
.addClass('active');
|
||||
};
|
||||
|
||||
return control;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue