Ciao, I have a Nav Menu in a header and Scroll Smoother with Lenis activated (amazing to have it btw). The anchor links jump directly to the corresponding section without scrolling. I’ve tried reading all the documentation but can’t find a solution (probably because my knowledge is limited). If it can be helpful, here is the page New - Col Tamarie. Can you help me solve this? Thank you very much.
To add smooth scrolling to Lenis, you can use the scrollTo
function:
The Lenis instance can be accessed with: BrfScrollSmoother.smoother
. So you could call the function like that: brfScrollSmoother.smoother.scrollTo(target, {})
Hope that gives you a direction. Mark this as no bug though.
Thank you, Daniele. I was able to implement it using Bricksforge Panel Events.
If it might be useful to someone as inexperienced as I am:
- Create a Nav (Nestable) and the respective Text Links (do not include the anchor in the URL).
- In the Bricksforge Panel, create an On Click Event by selecting a Text Link as the Trigger; for Action, choose JavaScript and insert this JavaScript code:
brfScrollSmoother.smoother.scrollTo(document.getElementById('my-anchor-section'), { behavior: 'smooth' }).
Replace ‘my-anchor-section’ with the ID of the section that the link should point to, omitting the #. - Duplicate the event for each Text Link, modifying the Trigger and the ID of the section to point to in the JavaScript.
I’m not sure if it’s the most correct way, but it works.