Skip to content

Conversation

@hartzis
Copy link
Collaborator

@hartzis hartzis commented Mar 21, 2019

right before i was about to release 5.1.0 found that the #131 added a bug where touch events were not being "cleaned up" if trackTouch was toggled. This pr "cleans up" the touch event listeners.

published as react-swipeable@5.1.0-alpha.2

  • test added that verifies that touch event listeners are removed
  • have to bump the size-limit too, just a bit with room to breath

src/index.js Outdated

// if new DOM el clean up old DOM and reset cleanUpTouch
if (state.el && state.el !== el && state.cleanUpTouch) {
newState.cleanUpTouch = state.cleanUpTouch()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

instead of setting up newState, do a transientState?

const transientState = {}
if (state.el && state.el !== el && state.cleanUpTouch) {
  state.cleanUpTouch()
  transientState.cleanUpTouch = null
}
...
return {...state, ...transientState}

Then we can be more conistent and clear with using state for checking and transientState for updating?

"size-limit": [
{
"limit": "1.8 KB",
"limit": "1.875 KB",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

annoying we need to increase this, but the benefit I believe is a more understandable solution and easier code to reason about

@hartzis hartzis merged commit 44e2c46 into master Mar 22, 2019
@hartzis hartzis deleted the fix-touch-event-cleanup branch June 26, 2020 20:54
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