-
Notifications
You must be signed in to change notification settings - Fork 715
CSS Snap Points: Event Model Missing #156
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
Comments
Yeah, def. |
Note: In the interest of wrapping up the existing set of functionality (which is well-specced and pretty much done), we're deferring the event model until a later level of CSS Scroll Snap. |
As far as I can tell, this produces the correct result in all cases. This closes w3c#156.
Up. @fantasai Isn't it time? |
@pavelkornev It is. I unfortunately don't have the expertise to draft something up, but I'm happy to accept proposals. :) They'd go into Level 2, but we can certainly start a draft as soon as there's something to put in it. |
I believe if a user scrolls or shrinks their viewport the snap should move the scrollbar to the center so it can be more responsive. Please see this for example and move your scrollbar to another position and then shrink the browser. https://codepen.io/anon/pen/jRjpQv |
@tunelinks your concerns are already handled in the spec with this language...
Though implementors have yet to implement this logic. Chime in on filings like these to encourage implementation.
Also, your concern isn't exactly related to the original issue above. |
Is this what I need to know to make a spec proposal? Or is there more documentation? |
@DrummerHead, yes, that (and the things linked from it) is a good starting point. I would also add that it is usually recommended to be very explicit about the uses cases you are trying to solve with your proposal. A problem that is obvious to you may not always be obvious to others, and unless we all understand what it is that we're trying to solve, it can be hard to agree on the best way to solve it. |
@DrummerHead The TAG drafted an "explainer explainer", which is maybe a good starting point. But basically, a proposal to solve this needs to A) define some syntax, B) explain at least at a high level the expected behavior, and C) explain some of the use cases it solves, with some examples. It doesn't have to be super formal, just so long as it communicates those three things. :) |
Would the events api be the only way to build pagination for a slider (to indicate which slide I'm on)? I currently need this but am not aware of a way to extract the current dom's index using the current CSS Snap Scroll implementation (here's a codepen). UPDATE |
Just to get the ball rolling, here is how I imagine an event model for scroll snapping could look like: Syntax
Type: snapped
Expected behaviorThe Use cases
That's just a rough draft and I probably missed some use cases and things required to cover them. Also note that the So I encourage everyone to comment on this idea and come up with more use cases. @scottjehl You mentioned three events, though I am not sure what Sebastian |
I suspect it's better to leave this out (as you did) unless there are extremely compelling use cases for that. Having potentially blocking JS calls in the middle of scrolling tends make browser engineers very sad. Other questions:
|
Proposals here should also keep in mind the proposed |
When the browser has landed on the snapped position and stopped moving. The "decided on a snap position" case is probably meant by the
A new event should be fired. The author can distinguish this re-snapping by checking
I tend to say yes for that case, because the snap position can change in that case. Not necessarily when the scroll container was already snapped before the change and is snapped to the same position after the resizing, as the spec. requires to re-snap at that position in that case. Though for consistency the event might also be triggered in that case.
Same as above.
As far as I can see, the specification currently doesn't define what happens for animations and transitions, i.e. whether snap positions are continuously adjusted or just when the animation or transition ends. If the snapped state is never left and the scroll container stays snapped at the same snap position, I'd say no event should be fired. Generally speaking, everytime the snapped state changes from "not snapped" to "snapped" a new Sebastian |
Thank you for the note, @smfr! The information related to snapping for the proposed The order in which they'd get fired is probably not that important as both are defined not to be cancelable and Sebastian |
I would like to also point to this request by me, aiming in a similar direction: https://webwewant.fyi/wants/65/ This is not just about events, but also about offering some sort of Scroll Snap API to programmatically scroll to certain snap points. As for the events, I proposed these two things which might be worth considering here:
|
Hey y'all! As a young web dev I am super excited for the implementation of this. How's it coming along? Also, thank you for being awesome! |
I agree that there should be a way to explicitly scroll to certain snap points. Though I believe that should be discussed separately from the event model discussed here. So I created #8558 for it.
Does this really require to know how many snap points there are? I think for a progress indicator it should be enough to know the target element. With that, you can easily calculate the progress.
Can you tell a concrete use case that requires a distinction between the two methods? Sebastian |
It would be useful if CSS Snap Points had an event model for events like say,
snapstart
,snapstop
, andsnapchange
. Currently, we can listen for scroll events and try to simulate these events, but it's hard to pinpoint when a native snap starts and ends, as opposed to a user-driven scroll.The text was updated successfully, but these errors were encountered: