mattbryson / TouchSwipe-Jquery-Plugin

TouchSwipe is a jquery plugin to be used with jQuery on touch input devices such as iPad, iPhone etc.
http://labs.rampinteractive.co.uk/touchSwipe/
Other
4.05k stars 1.68k forks source link

What is the best way to remove a swipe handler from a page? #359

Open ppetree opened 4 years ago

ppetree commented 4 years ago

Most frameworks load pages into the dom and when the user navigates away from that page it's removed from the dom and replaced with the page the user wants and when that happens the swipe hander(s) for the page being discarded are useless and just taking up memory. What's worse is that when the user navigates back to that page, the swipe handlers get set again.

So, what's the best way to remove a swipe handler from a page? Do you @mattbryson check to see if a swipe hander is already in place and overwrite it with the new handler? Do you @mattbryson ignore the second swipe handler? If we set a second swipe handler on an element do you overwrite the first one?

    $("#element").swipe("destroy");

According to the documentation here when you employ the "destroy" method you "Destroy the swipe plugin completely. To use any swipe methods, you must re initialise the plugin."

Destroying the swipe plugin completely is a bit much and also doesn't appear to be true.

I think this needs to be cleared up (especially in the documentation).