How to Add Smooth Scrolling to Your Webflow Site Using Linus Library

Published on
May 2, 2023

How to Add Smooth Scrolling to Your Webflow Site Using Linus Library

Smooth scrolling is an essential feature for enhancing the user experience on your website. In this tutorial, we will learn how to add smooth scrolling to your Webflow site using the Linus Library. Linus is a popular smooth scroll library for Webflow, featuring support for position sticky and native interactions. We'll cover the process of setting up Linus and explore specific requirements for using it in Webflow. By the end of this tutorial, you'll have a deep understanding of how to implement smooth scrolling with Linus on your Webflow site.

Getting Started

To begin the process of integrating smooth scrolling into your Webflow site using the Linus Library, you will need to follow these steps:

  1. Clone the Linus-enabled Webflow project from the description below the video.

  2. Once you have the Linus-enabled project, you can start exploring smooth scrolling on your Webflow site with Linus.

Setting Up Linus in Webflow

CSS and JavaScript Setup

Inside the page settings of the cloneable, you will find the necessary CSS recommended by Linus and the accompanying JavaScript. If you are working on a multi-page site, you would need to move this code to the project settings instead.

By default, Linus disables scrolling when you are logged into the Webflow editor. This is to ensure a smooth editing experience. The provided code ensures that Linus only runs when you are not in editor mode.

Additionally, there are optional settings that can be applied to configure Linus itself, along with methods to enable or disable scrolling the page with Linus. For instance, the code can be uncommented to activate scroll trigger if you are using it.

Adding Attributes for Scroll Control

Linus provides a set of attributes that can be applied to specific elements to control scrolling behavior:

  • data-linus-stop: This attribute can be applied to any link to disable scrolling on the page when the link is clicked. For example, this attribute can be used for links that open pop-ups.

  • data-linus-start: Conversely, this attribute can be applied to links, such as close buttons in pop-ups, to enable scrolling on the page when the link is clicked.

  • data-linus-toggle: When applied to a menu button, this attribute allows toggling between disabling and enabling page scrolling on successive clicks.

  • data-linus-prevent: This attribute is added to divs on the site that are set to "overflow: scroll" or "overflow: auto" to allow scrolling inside them, preventing Linus from disabling scrolling on these elements.

Configuring Linus Settings

Lerp (Linear Interpolation)

The Lerp setting in Linus is used to interpolate the current scroll position with a target position. A smaller lerp value results in a smoother animation. The default value for lerp is 0.1, and it accepts any value from 0 to 1. Adjusting the lerp value can affect the smoothness of the scrolling animation.

Duration, Easing, and Speed Control

While duration and easing settings are available, they become irrelevant if lerp is defined. The experience is smoothest when using lerp, but the speed of the scrolling can be adjusted using the wheel multiplier. Setting the wheel multiplier to a value above one will result in faster-than-normal scrolling, while a value below one will slow down the scrolling speed.

Touch Devices Settings

Smooth scrolling is disabled by default on touch devices, as it can feel unnatural. However, this can be changed by setting the smooth scroll to true and independently controlling the touch speed.

Scroll Orientation and Gesture Orientation

The orientation settings allow control over the scroll direction, whether it is vertical, horizontal, or both. Additionally, the gesture orientation setting allows specific control over scrolling patterns for trackpad users.

Infinite Scrolling

Linus provides an option for infinite scrolling, which means that when the bottom of the page is reached, it restarts at the top. This setting is turned off by default, but it can be enabled to create a seamless scrolling experience.

In summary, Linus offers a comprehensive range of settings and attributes to customize and control the smooth scrolling behavior on your Webflow site.

Demonstrating Infinite Scrolling Effect

As an additional step, you can implement the infinite scrolling effect using Linus. This effect gives the illusion of an endless scroll, where reaching the bottom of the page seamlessly restarts the scrolling experience from the top.

To showcase the infinite scrolling effect:

  1. Set the infinite attribute to true in the Linus configuration settings.

  2. Add CSS to hide the scrollbar, as it could disrupt the illusion of infinite scrolling.

For demonstration purposes, here's a basic example:

/* Additional CSS to hide the scrollbar */.section {  height: 100vh; /* Set the height of the first section to 100% of the viewport height for demonstration */}

By applying these settings and CSS, you can test and experience the infinite scrolling effect on your Webflow site.

Conclusion

In conclusion, implementing smooth scrolling on your Webflow site using the Linus Library provides an enhanced user experience and a polished, modern touch to your design. From setting up Linus in Webflow to configuring smooth scrolling attributes and demonstrating the infinite scrolling effect, you now have the knowledge and tools to incorporate smooth scrolling seamlessly into your Webflow projects. By understanding the settings, attributes, and configurations available within Linus, you can tailor the scrolling experience to match your specific design requirements and provide an excellent user experience for your site visitors.