Skip to content
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

[css-overflow-3] [css-ui-4] Draggable scrollers #9811

Open
bramus opened this issue Jan 17, 2024 · 8 comments
Open

[css-overflow-3] [css-ui-4] Draggable scrollers #9811

bramus opened this issue Jan 17, 2024 · 8 comments
Labels
css-overflow-3 Current Work css-ui-4 Current Work

Comments

@bramus
Copy link
Contributor

bramus commented Jan 17, 2024

(Not sure which spec this should go into, ergo not tagging it)

Whenever I see demos like https://codepen.io/supah/pen/xxJMbbg I’m wondering what it would take to make a scroller draggable on desktop (i.e. click + hold on the scroller and then move the pointer to change the scroll offset)

Yes, it can be done with a tad of JS but that’s blocking and would require authors to try and recreate the native fling curves to get it right, often leading to an uncanny valley type of situation as that’s OS dependent.

Ideally, to me, it would be a single CSS property that says “this scroller can be dragged to scroll”. When activated, clicking + dragging on the padding-box of the scroller will change the scroll offset in response.

While this has some implications such as not being able to select text in those scrollers (I guess), I don’t think this is a problem for things like https://scroll-driven-animations.style/demos/cover-flow/css/. Authors should be educated to only use this feature in certain situations.

@Loirooriol Loirooriol added css-overflow-3 Current Work css-ui-4 Current Work labels Jan 17, 2024
@Loirooriol
Copy link
Contributor

No tag just makes it easier to forget about issues. Scrolling containers are CSS Overflow, and interaction with the pointer seems CSS UI, so going with that.

@bramus
Copy link
Contributor Author

bramus commented Jan 17, 2024

Thanks, Oriol. I’ve updated the title to reflect this as well.

@bramus bramus changed the title Draggable scrollers [css-overflow-3] [css-ui-4] Draggable scrollers Jan 17, 2024
@yisibl
Copy link
Contributor

yisibl commented Jan 19, 2024

Yes, this interaction effect is very popular: https://twitter.com/didiercatz/status/1744065302088843508

I have a hack implementation: https://twitter.com/yisibl/status/1744691885606945102

drag-tabs.mp4

@argyleink
Copy link
Contributor

What if the way this was implemented was with a "full scrollport covering, invisible, track and thumb". No code would have to change in the engine, because to it, the user is just dragging the thumb inside the track. To the user, they feel like theyre panning. As if scrollbar-width accepted 100cqb or 100cqi.

@yisibl
Copy link
Contributor

yisibl commented Jan 22, 2024

What if the way this was implemented was with a "full scrollport covering, invisible, track and thumb". No code would have to change in the engine, because to it, the user is just dragging the thumb inside the track. To the user, they feel like theyre panning. As if scrollbar-width accepted 100cqb or 100cqi.

This may result in the specified tab not being clicked.

@yisibl
Copy link
Contributor

yisibl commented Jan 22, 2024

@argyleink I achieved a similar effect using scroll-snap + scroll-timeline, and I'm not sure it can be improved any further.

https://codepen.io/yisi/pen/abMwRGL

image

@donnysim
Copy link

donnysim commented Jun 16, 2024

This would be great, there's a lot of cases where the content converts into a slider on mobile or desktop. Having the ability to define ability to drag scroll with mouse would remove the need for most slider libraries and doing gymnastics on enabling or disabling them or sometimes even having slider running but with display: none; on breakpoints which is less than ideal. The scroll-snap is one part of the puzzle that takes us far but it does not work with js drag as it prevents any kind of scroll modification, which leads you to still pretty much implementing all the smooth scroll logic at which point is why even bother, just use a library.

For some situations like the active item or/and a number indicator n/total would still be acceptable to do with js as most of it can be easily achieved with intersection observers and that would still be a fraction of js that is needed for a full fledged slider, while at the same time just a minor hiccup with js disabled as most would still work.

For the text selection, browsers maybe could implement the same logic as with links, hold Alt to select the text without triggering the link etc..

@flackr
Copy link
Contributor

flackr commented Jun 17, 2024

I suggested a direct-manipulation (the spec term for pointer devices which scroll on down) over in pointer-events (which is where we have the related touch-action defined): w3c/pointerevents#203 (comment)

I've broken this out into its own pointer-events issue w3c/pointerevents#512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-overflow-3 Current Work css-ui-4 Current Work
Projects
None yet
Development

No branches or pull requests

6 participants