DEV Community

Adam Crockett ๐ŸŒ€
Adam Crockett ๐ŸŒ€

Posted on

Scroll snap - one at a time

I have this sandbox here, it's an implimentation of two off canvas menus left and right, it's meant to feel native on a mobile by allowing you to drag across to reveal a menu. For the most part it's working well, not a lot of JavaScript is used and the idea isn't really complex which is nice because this sort of thing used to be a real pain.

What I am wondering is how can I force it to scroll one at a time either in js or css. You can over scroll from one side to another with a little force. I want to swipe hard and always arrive in the middle the swipe again to open the other menu.

The sandbox probably doesn't work in this embedded frame so you might have to view the code.

Top comments (3)

Collapse
 
daniel13rady profile image
Daniel Brady

Sorry, I have no aid to give this time around, but I just wanted to say that Iโ€™m viewing this on tbe iOS DEV app, the embedded sandbox works, and I really like the experience! ๐Ÿ˜„

I look forward to seeing the outcome here.

Collapse
 
adam_cyclones profile image
Adam Crockett ๐ŸŒ€ • Edited

That's nice to know thanks Daniel I'm carrying on building with this technique and will probably refine with JavaScript later.

Collapse
 
adam_cyclones profile image
Adam Crockett ๐ŸŒ€ • Edited

scroll-snap-stop: always; this stops over-scrolling! here is V2