loopj / jquery-simple-slider

Unobtrusive numerical slider plugin for jQuery
194 stars 113 forks source link

Click & drag event not firing on touch enabled devices #54

Open ccarv opened 10 years ago

ccarv commented 10 years ago

Tested on Android KitKat 4.4.2:

Fails to detect click and drag. More than likely due to native navigation functionality on touch enabled devices.

--edit

Just noticed a touch-support branch but unfortunately I still wasn't able to get it working. It recognizes that the device I am using is a touch-enabled device, except dragging is still failing. Not only that but it appears the click (click anywhere on the slider except on the drag button) event is no longer firing either.

ravinderk commented 10 years ago

I'm experiencing the same issue. Its not working on touch enabled devices. I think it should be a priority since almost everyone is using touch enabled devices.

rjm101 commented 10 years ago

Same problem here. Tested on Google nexus 10 tablet.

zackyp commented 10 years ago

I encountered the same issue (dragging is not working on mobile devices). After some minor updates to the code I came up with a working solution. Just add the following to the source's SimpleSlider class (function):

  // Zacky: mobile support
  this.dragger.bind('touchstart', function(e) {
    _this.dragging = true;
    _this.dragger.addClass("dragging");
    _this.domDrag(e.originalEvent.touches[0].pageX, e.originalEvent.touches[0].pageY);
    return false;     
  });

  $("body").bind('touchmove', function(e) {
    if (_this.dragging) {
      _this.domDrag(e.originalEvent.touches[0].pageX, e.originalEvent.touches[0].pageY);
      return false;
    }
  }).bind('touchend', function(e) {
    if (_this.dragging) {
      _this.dragging = false;
      _this.dragger.removeClass("dragging");
      return $("body").css({
        cursor: "auto"
      });
    }
  });
yoeran commented 10 years ago

Same problem here. @zackyp's solution works like a charm.

neugartf commented 10 years ago

@zackyp this should really go into master branch

kshipp commented 9 years ago

Same problem here. @zackyp's solution works like a charm.