Skip to content

Conversation

@dominicbarnes
Copy link
Member

Currently, the window events can be bound multiple times in some cases. If the hide is cancelled,
then show is called again (ie: mouseover/out fun times) the winEvents simply get bound again,
causing the previous handler to be forever bound (since unbind only gets the last one in the stack
apparently, probably needs to be addressed in component/events somehow)

This could probably be addressed more completely by using mouseenter/leave instead of mouseover/out,
but that is not addressed in this commit.

Currently, the window events can be bound multiple times in some cases. If the hide is cancelled,
then show is called again (ie: mouseover/out fun times) the winEvents simply get bound again,
causing the previous handler to be forever bound (since unbind only gets the last one in the stack
apparently, probably needs to be addressed in component/events somehow)

This could probably be addressed more completely by using mouseenter/leave instead of mouseover/out,
but that is not addressed in this commit.
@Swatinem
Copy link
Contributor

Swatinem commented Apr 4, 2014

Reading the code, the difference between .events and .handleEvents is really confusing.

The .events case set up in cancelHideOnHover does not do a show, so you would completely unbind the events in that case.

@dominicbarnes
Copy link
Member Author

Yeah, looks like if a user cancels the hide manually, that would remove the winEvents altogether.

The real trouble imo is that component/events is not aware of the fact that the same method is being bound repeatedly. (and once that happens, there is no way to unbind it)

@pirxpilot
Copy link
Member

If we are concerned about not registering events more than once let's create winEvents (only if it does not exist) in show and then unbind all in remove and reset winEvents to null: should be safer than predicting all the possible sequences of registering and unregistering window events.

pirxpilot added a commit that referenced this pull request Apr 8, 2014
ensure that 'scroll' and 'resize' handlers are in all cases bound at
most once, and that they are always unbound when Tip is removed

fixes #38
fixes #25
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.

4 participants