-
-
Notifications
You must be signed in to change notification settings - Fork 336
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
[slider] Add option to disable touch-/mouse-sliding on the track #1987
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a testcase using your latest code
Try this on real mobile devices (i did on my Android Xperia 5ii)
https://fomantic-ui.com/jsfiddle/#!lubber/thr6dvLp/1/
The current code does not seem to work on real mobile devices at all. No matter if i touch or swipe on the track: It is always doing the same for me (as before: changing the slider immediatly)
It is also not completely working as expected when using on desktop browsers:
https://jsfiddle.net/lubber/thr6dvLp/1/
The mouse event does indeed not change the slider on mousedown and drag... but when i release the mouse button after the drag, the slider thumb still gets repositioned to where i released the mouse button. I think your intention was to not change the thumb at all then.
Desktop
Modile (using Browserstack on a Samsung Galaxy S21)
Oh, yes, you are right. This is due to the logics screwup in line 286 that you already commented on. I actually used the new setting the wrong way round for touch events on the However, the
This is due to the definition of the ´click` event. From MDN:
The only way to prevent this, would be implementing a custom "click detection" which uses move events to cancel a click when moving more than a fixed pixel delta from the original click position. I could do this, but I don't think it's worth the additional required code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a jsfiddle with your latest code.
Unfortunately it is completely broken on desktop for when slideEverywhere is true (which is default and would break every existing code)
https://jsfiddle.net/lubber/thr6dvLp/2/
The first example does not work at all anymore on desktop and throws a console error when you click/hover on the slider
On mobile i can still drag from inside the track in the second example.
https://fomantic-ui.com/jsfiddle/#!lubber/thr6dvLp/2/
Ah, sh*t. I'm sorry for wasting your time with testing my broken patches. Unfortunately, I cannot reproduce the dragging issue in the second example. I tested the latest version locally and the previous version with your JS fiddle link on Chrome mobile 91.0.4472.101 on Android, Firefox mobile 89.1.1 on Android and Safari mobile on iOS. On all three browsers, the behaviour is as intended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New jsfiddle using your latest commit:
https://jsfiddle.net/lubber/thr6dvLp/3/
https://fomantic-ui.com/jsfiddle/#!lubber/thr6dvLp/3/
Please see my question about the different event name
Also, the setting still does not work on desktop as mentioned. When releasing the mousebutton the thumb still gets repositioned even if dragged from within the track. @fomantic/maintainers Your opinion?
As I explained above:
|
Yes, that's why i wanted the other maintainers to have an opinion if/how we deal with that. I otherwise smell people complaining the feature does not work on desktop...just saying 😉 |
Sorry, I misinterpreted that as a criticism on my fixes. Another compromise could be to restrict the new setting on touch events. I.e. with |
Wasn't my intention, sorry, if you felt so. 🤗
Oh, you are thinking about providing a solution for those two issues (#1988 and #1989 ) ? 🥰 Great! 👍🏼 Then i suggest to think about an overall solution which also possibly fixes/covers those two issues as well before merging this PR (to avoid having the need to revert something later) |
Mmmmmh... Can't we determine if pointer get out of the component zone, and then cancel the movement ? This seem to be a delicate issue tbh. |
As proposed in #1988, I did a rework of the touch event handling of the slider component. The new touch event code does not prevent mouse input (fixes [slider] cannot move slider using mouse on iPad #1988) tracks Touch identifier to avoid confusion by other fingers on the touch screen handles touchcancel events in a sensible way does no dynamic binding and unbinding to all touch events on the page. In combination with the second point, this enables multitouch sliding of multiple sliders on the same page (I know, nobody asked for this, but it works. ;) ) – Unfortunately, multitouch sliding of the first and second thumb of the same slider is not easy to implement due global state within each slider module. only binds to touchstart events on the .thumb element to avoid accidential sliding while scrolling the page on a mobile device (obsoletes [slider] Add option to disable touch-/mouse-sliding on the track #1987) The last point can be considered a disadvantage/regression compared to the old code, if you consider touch-sliding anywhere on the slider as a feature. However, in my experience, it's really annoying to change a slider position (which has immediate real-world effects in my home automation software) when scrolling the page and accidentially hitting a slider. Using the mouse, one can still slide the slider anywhere on its track.
Since #2327 is merged, i think we can close this? |
I made a simple replacement PR #2330 based on the current code. Please check |
Description
Currently, the slider is quite sensible to mouse and touch events: Any mouse drag and touch event that starts anywhere on the slider will move the knob (not only when hitting the knob). This is especially annoying when trying to scroll a page with many sliders on a mobile device with touch screen. You'll find yourself moving a slider accidentially quite often.
Thus, this PR introduces a setting
slideEverywhere
to sliders to change the click and touch behaviour. By default, it istrue
, which corresponds to the old behaviour. WithslideEverywhere=true
, the slider can only be moved by either dragging the knob or by clicking / tapping (not dragging) anywhere on the slider.Testcase
https://jsfiddle.net/81cs7dbg/1/
Screenshot (if possible)
Does not change anything visually.