HubSpot/drop — pull request #4 by thauburger (2014-01-30 00:31:38+00:00)
Title: Add support for devices with both touch and mouse input.

Hey HubSpot,

I saw Tether on Hacker News earlier today, and think it looks great. I did notice, however, that the example projects hosted on [tether.io](http://tether.io) (e.g. Drop) do not always work on devices that have both touch **and** mouse input capabilities.

In `drop.coffee`, the following logic is used to determine which type of "click" event should be supported, based on the presence of `ontouchstart`:

```coffee-script
touchDevice = 'ontouchstart' of document.documentElement
clickEvent = if touchDevice then 'touchstart' else 'click'
```

This works great for touch-only or mouse-only devices, but for dual-input devices (e.g. Chromebooks, Windows 8 touch laptops, etc.), using this logic essentially blocks the mouse from being used, because only touch events are handled. In quick testing, I was able to successfully "touch" the demo projects on a Chromebook, but couldn't interact with the "Drops" by clicking. You can simulate this by [enabling touch events](https://developers.google.com/chrome-developer-tools/docs/mobile-emulation) in a Chrome desktop browser.

This PR addresses the problem by adding multiple event handlers on devices where multiple inputs are supported.

I think this change would also be applicable to other Tether-based projects (e.g. Select, Tooltip), but I didn't want to create the additional PR's until this one was accepted / rejected.

Additionally, there is further optimization that could be done for "modern" IE versions (e.g. explicitly handling [MSPointer](http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx) events), but I left this out, as there is a solid fallback using the `click` event.

Let me know if this is helpful. Thanks for the cool projects!

Best,

Tom