bootstrap-slider icon indicating copy to clipboard operation
bootstrap-slider copied to clipboard

Touch Events Propagate to Page Scroll

Open PowerOfM opened this issue 8 years ago • 5 comments

Touch events are not stopped when trying to drag the handle of a slider, resulting in the page being scrolled before the slider can change. This makes it especially difficult for vertical sliders, where it's nearly impossible to change the value without the page scrolling first.

For a quick demo, take a look at this JSFiddle through your phone or using Chome DevTools (as explained in the fiddle).

It appears that the page-scroll event takes precedence over the slider (or the touch event isn't captured/stopped), since once you reach the top of the page, you can drag the slider down.

I've tried inserting some preventDefault()'s into the touchstart handler but to no avail. If anyone even knows of a quick work-around, I'd really appreciate it!

PowerOfM avatar Oct 19 '16 04:10 PowerOfM

@PowerOfM we just published a new feature in v9.7.0 that may address your use case

https://github.com/seiyria/bootstrap-slider/blob/master/CHANGELOG.md#970--2017-01-05

rovolution avatar Jan 05 '17 06:01 rovolution

Having the same issue for a horizontal slider in mobile devices. I see @powerOfM JSFiddle is using the 9.7.0 and this does not seem to be fixed. Are there any parameters to be set @rovolution ?

Sroose avatar May 24 '17 08:05 Sroose

@Sroose nope 9.7.0 was just an implementation change, so it that didnt do the trick then this is still an outstanding issue. we would welcome a PR to fix it!

rovolution avatar May 24 '17 14:05 rovolution

Since this was a blocking issue for me, I moved to 'nouislider' which works well across devices.

Sroose avatar May 28 '17 20:05 Sroose

@Sroose I just found that this can be solved by adding the css property touch-action: none on the .slider class. More about touch-action here

This adjustment works with 9.7.0, but not with the latest release, 9.8.0. I didn't see any notes on changes to touch-handling in the changelog, so I'm not sure what broke.

PowerOfM avatar May 28 '17 21:05 PowerOfM