How scroll with smoth animation using anchor and <Link> component ?
Unanswered
Fire ant posted this in #help-forum
Fire antOP
Hi, i want to scroll with smoth animation when i m using the <Link> component, because on my case i don't know how to do, it's doesnt have animation and it position the element to the top, i want it centered.. Thank you !
6 Replies
you need to set it to smooth
and use <a> tag for scrolling to certain sections and not Link tag
Fire antOP
Thank you, why i need to use <a> tag and not <Link> tag ? Other thing, i have a fixed element (the header) i need more marging when the anchor make the app scroll into the element, there is something i could do ? I just do not want to make strange customized code ^^
@Fire ant Thank you, why i need to use <a> tag and not <Link> tag ? Other thing, i have a fixed element (the header) i need more marging when the anchor make the app scroll into the element, there is something i could do ? I just do not want to make strange customized code ^^
It is discourages to use Link tag for scrolling on same page.
For extra margin, you need to listen to scroll event in useEffect and add css styles accordingly
For extra margin, you need to listen to scroll event in useEffect and add css styles accordingly
Fire antOP
Hmm ok, i used useEffect, it's working when i click on the link button, now the difficult part it's just to add the extra marging when i refresh the url with #anchor (without clicking on the link element),