sweet-scroll | TypeScript Friendly , dependency-free smooth scroll library | Frontend Framework library
kandi X-RAY | sweet-scroll Summary
kandi X-RAY | sweet-scroll Summary
ECMAScript2015+ & TypeScript Friendly, dependency-free smooth scroll library.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of sweet-scroll
sweet-scroll Key Features
sweet-scroll Examples and Code Snippets
Community Discussions
Trending Discussions on sweet-scroll
QUESTION
What's the best approach for adding an onclick event to trigger a scroll for an element that has horizontal overflow?
Premise: I'd like to add an anchor nav that allows a user to jump to specific milestones in a timeline UI. I'm working from this example EnvatoTuts. By grabbing the first instance of a year I'm attaching an ID to the milestone and building out an anchor nav.
Things I've tried: It seems most information is in regards to vertically scrolling the html or body, where as I'm looking to only scroll horizontally within div.
- I tried using smooth scroll, but because the action is horizontal the browser 'jumps' down to the anchor
- I tried using
position:fixed
on the anchor nav, but this takes the nav out of the parent container, attaching it to the viewport - I tried using
translateZ(0)
on the container element (.timeline
), butposition:fixed
does not actually work on the anchor nav because the position essentially reverts back to relative - I tried using a plugin for scrolling (sweet-scroll), but couldn't figure out how to trigger scrolling with the nav outside of the target container
Here's the javascript I've used to set an ID and build the anchor nav:
...ANSWER
Answered 2018-Jan-03 at 17:30I solved for the above issues with a bit of CSS:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sweet-scroll
Load it in the script tag.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page