Venturocket / angular-slider

Slider directive for AngularJS.
MIT License
262 stars 121 forks source link

Touch Events Not Working #54

Open ben-sykes opened 10 years ago

ben-sykes commented 10 years ago

Seems there is an issue with pulling 'clientX' from the captured events. I believe event.touches[0].clientX is not being captured, or not being accounted for properly.

Please see OnMove (Line 1419) and OnStart (Line 1623) functions. (Angular-slider.js --Version 0.3.2)

If I add " || event.touches[0].clientX; " to that line, the sliding works, but throws an error (probably just needs some additional checks)

Has anyone else experienced this issue? Or hopefully I just overlooked something simple.. I'll try to throw a punkr together this evening.

ben-sykes commented 10 years ago

http://plnkr.co/edit/HNusw03NPBOxg4hDgh50

Edit: Of course, view this either in Chome emulator or on your phone...

ben-sykes commented 10 years ago

Please, could anyone else at least test this quickly to let me know this isn't just a problem with how I'm using it..?

wisdom2014 commented 10 years ago

I have the same problem, the slider is not responding to touch events. I hope this will be fixed soon because this slider works quite good on desktop with mouse.

ben-sykes commented 10 years ago

Try adding the extra condition " || event.touches[0].clientX; " to the following lines:

For me, this fixes the complete functionality loss but throws an error in the console (due to me not checking everything completely I'm sure). Its not a showstopping error so I haven't devoted any more of my own time to it... yet. Was hoping this guy actually maintained his projects.

dasblitz commented 10 years ago

Tnx, I just added this but instead used event.changedTouches[0].clientX can't see any errors. Strange that this fix is needed though, since the events should be coming from $swipe which should have an x value

ben-sykes commented 10 years ago

Thank you so much for your response! Seems as though I was just pointing to the incorrect event. You're exactly right though about $swipe. It is odd.

ejensler commented 10 years ago

+1 to @dasblitz's fix. I had wanted to include this slider in my project for months, and ended up going with a far inferior html-5 range input. I'm not experienced enough with touch events to have debugged this issue myself, so many thanks.

ejensler commented 10 years ago

It's also important to note that if your project uses jQuery, jQuery appears to wrap touch events, so instead of event.changedTouches[0].clientX, it should be event.originalEvent.changedTouches[0].clientX.

Litande commented 9 years ago

kinda new to this, @dasblitz note about event.originalEvent.changedTouches[0].clientX return the right position of the touch event, the errors where thrown on "touchend" event which has no touches, i solved this by removing the calles to OnMove inside bindSwipe function Line 1755 and bindSlider Line 1685, does anyone see any critical error in this?