Posts

Showing posts from April, 2021
Image
Sticky Scroll to Top Button in LWC Hi Folks, This is a very simple requirement but often we get stuck and while googling about it we don't find a solid solution that would directly work in Salesforce LWC. Here I am writing my blog which can be used in your LWC directly, just need to follow the below points. Few points before jumping on to the entire code. We are going to use the Element.scrollTop property to control the scroll bar. This code works if you have a specific Scroll Bar for your element . Meaning you have added a custom scroll bar for your <div> How to do that? First, add a topmost div with a class and an onscroll method which would be able to calculate at which position is your scroll bar is currently. < div class = "top-most-div" onscroll = {onScroll} > <!-- All your other code--> </ div > Add the CSS for the top-container .top-most-div { overflow-y : scroll ; height :80 vh ; scroll-behavior : smooth ; } If you want ...