Skip to content

Latest commit

 

History

History
69 lines (42 loc) · 2.52 KB

README.md

File metadata and controls

69 lines (42 loc) · 2.52 KB

mobile-monkey

Touch event support for regular ol' jQuery

mobile-monkey simulates mouse events on touchscreens in the same way jQuery UI Touch Punch does, only mobile-monkey patches jQuery's .on handler to provide a general patch for your entire application.

Why would I use this?

You may notice a delay on your site when you use a touchscreen. This is because nearly all touchscreen devices have a 300ms delay between firing the touchstart event and firing the click event.

Use this patch to invoke your handler earlier, providing a great experience on touch devices.

mobile-monkey even provides the necessary touch capabilities for jQuery UI!

Caveats

  • mobile-monkey currently only supports click events in non-delegation handlers.

  • mobile-monkey will not patch handlers bound to document, html, or body. Binding mobile-monkey to these elements prevents the user from scrolling with their touchscreen.

  • mobile-monkey does not dispatch click when the original touch target is an input or textarea. This is because by the time the click event has fired, the keyboard has appeared and the event x, y coordinates are no longer correct. This will hopefully be solved in the future

  • This is a monkey patch; a hack. Soon, Pointer events will be regularly consumable without awkward polyfills that require you to rewrite large portions of your site, and we can stop with this nonsense.

Usage

  1. Grab jquery.mobile-monkey.js from the repository and add it to your project.

  2. Include jQuery and mobile-monkey on your page.

    <script src="//code.jquery.com/jquery.min.js"></script>
    <script src="jquery.mobile-monkey.js"></script>
  3. And you're set! Your click handlers will now get fired much sooner, giving touchscreen users a much more pleasant experience on your website.

Tested on iPad, iPhone, Android and other touch-enabled mobile devices.

Thanks, Dave

Thanks to Dave Furfero for making a great and useful plugin!

Visit the official Touch Punch website.

mobile-monkey is a derivative work of jQuery UI Touch Punch and is dual licensed under the MIT and GPLv2 licenses.

Original copyright: Copyright 2011–2014, Dave Furfero