Skip to content
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

Hide position indicator on layer 'mouseout' #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nrenner
Copy link
Contributor

@nrenner nrenner commented Jun 16, 2016

The position indicator/marker on the diagram remains at last position after hovering over the data layer on the map. This adds a mouseout listener to the layer to remove the diagram indicator.

@nrenner nrenner mentioned this pull request May 7, 2018
@@ -669,6 +669,7 @@ L.Control.Elevation = L.Control.extend({
}
if (layer) {
layer.on("mousemove", this._handleLayerMouseOver.bind(this));
layer.on("mouseout", this._hidePositionMarker.bind(this));
Copy link

@fbonzon fbonzon May 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem if the elevation profile is removed from the Leaflet map. The layer would still have listeners pointing to an elevation profile that no longer exists. I think we should take care of removing listeners too.

Try this. Here, change lines 670-673 to:

        if (layer) {
            this._layer = layer;
            layer.on("mousemove", this._handleLayerMouseOver, this).
            on("mouseout", this._hidePositionMarker, this);
        }

And add in onRemove at top of file:

        if (this._layer) {
            this._layer.off("mousemove", this._handleLayerMouseOver, this).
            off("mouseout", this._hidePositionMarker, this);
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I guess in theory addData could be called multiple times, so we would need to keep a list of layers. clear should probably also remove listeners.

I won't update this right now, maybe later. Feel free to share an alternative PR and I'll close mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants