-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New event to hide/show all elements #85
New event to hide/show all elements #85
Conversation
Hiding and showing slices is available through a click on legend element (if `legend.area.hideElemsOnClick.enabled` if set to true). I needed a function to hide/show all elements at once. This patch implements a new event call `hideAllElems` which accept a boolean parameter `hide`. It allows to show/hide all elements at once. I'm up to debate for this event name, but I think it's the most simple and similar to `hideElemsOnClick`. Also, it corrects an issue in the `update` event where the *Reset hidden map elements* parts would never do its job because `el.hidden` is actually never set (no error was thrown since we check for its existence, but it didn't do anything).
} | ||
}); | ||
}); | ||
$self.trigger("hideAllElems", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I miss an issue... This should be set to false of course...
$self.trigger("hideAllElems", false);
My bad...
This was an issue introduced in last patch. The `update` event shall reset the map elements (i.e. show them).
Hello, Thank you for the PR ! I think Regarding the name, we could keep 'hideElemsOnClick', or maybe something like that : 'toggleLegendElemsState' will be more explicit (but a bit too long ?) |
Right! Good catch :-) Regarding the name, the thing is that this event hide or show all the elements. This is not a toggle: elements already hidden will stay hidden for instance (or already shown will stay shown). |
Thank for the fix :) What do you think about "updateLegendElemsState" instead ? Otherwise, we will keep 'hideElemsOnClick' for the event name. |
However, the more I think of it, the more I wonder if we shouldn't integrate this inside the existing |
I didn't thought about this alternative, but I agree with you, I think that the 'update' event is an appropriate place ... and no more headhache to choose the event name :) Could you update the PR to move the code within the 'update' event as you have explained ? I think I will clean the "update" event signature later (and make it backward compatible with the current signature) in order to have a single object as parameter and get something like that :
|
Here is the commit. What do you think? |
Regarding the cleaning of |
It's ok for me, approved ! |
New event to hide/show all elements
Hiding and showing slices is available through a click on legend element (if
legend.area.hideElemsOnClick.enabled
if set to true).I needed a function to hide/show all elements at once (and it seems related to #26, no workaround would be needed).
This patch implements a new event call
hideAllElems
which accept a boolean parameterhide
. It allows to show/hide all elements at once. I'm up to debate for this event name, but I think it's the most simple and similar tohideElemsOnClick
.Also, it corrects an issue in the
update
event where the Reset hidden map elements parts would never do its job becauseel.hidden
is actually never set (no error was thrown since we check for its existence, but it didn't do anything).