Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Slider Touch not working with directive

I am using the following directive in my application

https://github.com/prajwalkman/angular-slider

It's all working ok apart from touch support when I'm trying to drag the sliders across the screen. Touch works on the examples given but not on my application. I have checked I'm using the same version of angular etc.

My code: filter.js (Controller)

$scope.lower_price_bound = 50;
$scope.upper_price_bound = 3000;

html

<slider floor="10" ceiling="3000" ng-model-low="lower_price_bound" ng-model-high="upper_price_bound"></slider>

Do I need to add anything to get touch support for mobile devices?

Thanks!

like image 274
jeh Avatar asked Sep 08 '26 07:09

jeh


1 Answers

For anyone still experiencing this issue, this might help: JS: How does event.touches property work? "It sounds like jQuery isn't passing the touches property on in its custom event object."

This fixed it for me. Change this:

onMove = function (event) {
              var eventX, newOffset, newPercent, newValue;
              eventX = event.clientX || event.touches[0].clientX;
              ...

to

 onMove = function () {
              var eventX, newOffset, newPercent, newValue;
              eventX = event.clientX || event.touches[0].clientX;
              ...

(line 227 on my version of angular-slider.js)

like image 122
Ryan Avatar answered Sep 10 '26 20:09

Ryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!