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

'onTouchMove' listener is causing issues after removing all listeners #18

Closed
davidalee opened this issue Apr 4, 2017 · 7 comments
Closed

Comments

@davidalee
Copy link

davidalee commented Apr 4, 2017

I'm experiencing an issue when I toggle between two pages in my app. The first page has the pull to refresh feature, the second page does not have this feature so when the user navigates to the second page, I invoke the destroy method to remove the listeners. But when I scroll on the second page, I get an error

TypeError: Cannot read property 'classList' of undefined at _onTouchMove

and all of my content disappears.

@faelsoto
Copy link
Member

faelsoto commented Apr 5, 2017

It would help wonders if you could create a demo with this issue, so we can reproduce and fix the problem.

@davidalee
Copy link
Author

davidalee commented Apr 5, 2017

Apologies, I started working on a plunker for this but couldn't finish it due to work stuff. Essentially an touchmove event exists on the window even after the destroy method has been invoked (try getEventListeners(window) in chrome devtools console after invoking destroy()).

@davidalee
Copy link
Author

davidalee commented Apr 5, 2017

I'm trying to create a plnkr to reproduce this issue, but I'm having issues initializing the library, not sure why. It's pretty simple to reproduce the issue however, I'll lay out the steps here.

In order to reproduce this error, open up any app using this library in Chrome and invoke destroy() after initializing the library. Use getEventListeners(window) (only works in Chrome devtools) and you'll see that there still exists an event listener for the touchmove event although the other two event listeners that were initialized have been removed.

If you re-initialize the library at this point and check the event listeners, you'll see that the other two touch events have been added but now there are two touchmove listeners whereas there should be just one, the one that was just added as well as the listener that was not removed from the first initialization.

If you remove the { passive: false } on line 204 in /dist/pulltorefresh.js (when the event listener is added) and try running through the same steps listed above, all events including touchmove are removed properly after invoking destroy().

@davidalee
Copy link
Author

It seems there is already a PR that addresses this issue:

#15

@UziTech
Copy link
Contributor

UziTech commented Apr 5, 2017

does it work to add { passive: false } to the removeEventListener call on line #284?

Like this:

window.removeEventListener('touchmove', handlers.onTouchMove, { passive: false });

@UziTech
Copy link
Contributor

UziTech commented Apr 6, 2017

@davidalee I tried to reproduce this but destroy worked to remove the touchmove event for me.

What version of chrome are you using?

Chrome Version 58.0.3029.41 (Official Build) beta (64-bit)
Windows 10

image

@pateketrueke
Copy link
Collaborator

Hi guys, closing this since I've merged the pending PRs. 👍

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

No branches or pull requests

4 participants