Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
In a previous post, How to detect scroll direction in vanilla JavaScript (to make a goofy logo animation), I describe how to determine if a user is scrolling up or down. I use a scroll event listener to react to the user's scroll activity. I also discuss how a throttle function can improve the performance of the scroll event handling. I will use the throttle function from the lodash library in this example. If you are not familiar with throttling, give the post a read to understand it fully.
I use an icon rather than text inside the link to keep the size small. I choose the "chevron-up" icon with the solid fill from hero icons. I copied the SVG and pasted inside the a element. We will set the size of the icon in CSS later.