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

Ignores mouse on touch-compatible device #117

Closed
andrewdixie opened this issue Jan 5, 2014 · 2 comments
Closed

Ignores mouse on touch-compatible device #117

andrewdixie opened this issue Jan 5, 2014 · 2 comments

Comments

@andrewdixie
Copy link

In the following code it does not bind to "click" if "ontouchstart" exists.

On a Windows 8 laptop with both touch-screen and mouse, mouse clicks on sidr are ignored.


    if('ontouchstart' in document.documentElement) {
      $this.bind('touchstart', function(e) {
        var theEvent = e.originalEvent.touches[0];
        this.touched = e.timeStamp;
      });
      $this.bind('touchend', function(e) {
        var delta = Math.abs(e.timeStamp - this.touched);
        if(delta < 200) {
          e.preventDefault();
          methods.toggle(name);
        }
      });
    }
    else {
      $this.click(function(e) {
        e.preventDefault();
        methods.toggle(name);
      });
    }
@kdmurthy
Copy link

This is also true of FireFox on OSX which returns true for the condition. Looked around and found this: http://www.stucox.com/blog/you-cant-detect-a-touchscreen/

IMO, The best solution is to bind to both.

artberri added a commit that referenced this issue Jan 9, 2016
…ixes #179 and fixes #266 and fixes #246 and fixes #245 and fixes #211 and fixes #178 and fixes #118 and fixes #98  and fixes #214 and fixes #117 and fixes #130 and fixes #144 and fixes #146 and fixes #165 and fixes #189 and fixes #193 and fixes #203 and fixes #213 and fixes #218 and fixes #240 and fixes #249
@artberri
Copy link
Owner

artberri commented Jan 9, 2016

Preparing a new version with a fix for this https://github.com/artberri/sidr/tree/reborn

@artberri artberri closed this as completed Jan 9, 2016
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

3 participants