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

Fix touch event cleanup #132

Merged
merged 5 commits into from
Mar 22, 2019
Merged

Fix touch event cleanup #132

merged 5 commits into from
Mar 22, 2019

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 [email protected]

  • 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?

@@ -21,7 +21,7 @@
},
"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.

1 participant