Skip to content

Instantly share code, notes, and snippets.

@ApoGouv
Created March 28, 2021 05:57
Show Gist options
  • Save ApoGouv/a4c81c12884b3ddc9bf6c876da487e41 to your computer and use it in GitHub Desktop.
Save ApoGouv/a4c81c12884b3ddc9bf6c876da487e41 to your computer and use it in GitHub Desktop.
JS scripts for common and not only solutions

jQuery - Add support for passive event listeners

| There is an open issue here: jquery/jquery#2871

// Passive event listeners
jQuery.event.special.touchstart = {
    setup: function( _, ns, handle ) {
        this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") });
    }
};
jQuery.event.special.touchmove = {
    setup: function( _, ns, handle ) {
        this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") });
    }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment