Create Captivating 3D Scroll Interaction Using Webflow and Spline: Step-by-Step Guide

Published on
September 1, 2023

Creating a 3D Scroll Interaction Using Webflow and Spline

In this lesson, we will learn how to create a captivating 3D interaction using Webflow and Spline. This interaction will allow users to scroll and scrub through an animation. Let's delve into the step-by-step guide to building this captivating 3D scroll interaction seamlessly.

Getting Started with Spline

We begin by heading to the Community Tab in Spline and search for the cubic model that we wish to use. Once located, we can use the first model in our project and then select "Remix". Upon remixing the model, we should proceed to set the frame size to responsive to ensure it covers the entire screen.

At this point, we have two states within our object. For the base state, lock the scale and scale it up significantly while adjusting its position to the left. In the subsequent state, scale it down to a point where it's almost in view and push it towards the right, allowing it to hang off the edge of the screen.

To create the transition between these two states, we utilize an onstart event, setting the transition to occur over a period of two seconds. Previewing the animation will showcase the seamless movement between the defined states.

Setting Scroll Interaction in Spline

We can also define the scroll interaction by creating a new state, locking the scale, adjusting its position, and incorporating a subtle rotation effect. With the state set, we proceed to create a scroll event in which the canvas serves as the trigger. This scroll event commences when the bottom of the element reaches the bottom of the screen and continues for a defined distance.

Upon configuring the scroll event, we navigate to the export section to set the play settings. Here, we disable the logo and background color, and also eliminate the orbit pan and zoom for mobile. Additionally, we can incorporate an on-hover feature to enable the camera to slightly rotate and follow the cursor.

Once all these settings are configured, we can proceed to test the animation to ensure it functions as intended.

Implementing the 3D Scroll Interaction in Webflow

To seamlessly integrate the 3D scroll interaction created in Spline into Webflow, we can follow the steps outlined below:

Adding the Spline Exported Code to Webflow

  1. Begin by exporting the animation from Spline and click on "Copy Embed".
  2. In Webflow, add an embed element and paste the copied Spline code.
  3. Assign a class to the embed element, such as "embed", and define its height as 100 VH.
  4. Once the changes are made, publish the project to test the initial integration.

Upon integration, you will notice that the scroll interaction only initiates when the bottom of the canvas reaches the bottom of the screen. However, as users continue to scroll, the animation moves out of view. To address this, the next step is to make the embed sticky, ensuring the entire interaction is visible while scrolling.

Making the Embed Sticky in Webflow

To make the embed sticky, wrap the embed in a div block and assign it a class of "track". Define the height of the track block dynamically based on the height of the embed and the additional distance the animation covers after reaching the bottom of the screen. This can be achieved by setting custom CSS for the track height to 100 VH plus a thousand pixels, representing the continuation of the animation beyond the viewport.

Fine-tuning the Scroll Interaction

With the embed now sticking as intended, additional adjustments can be made to optimize the user experience. For instance, the top margin of the track can be set to a negative value relative to the hero section's height, ensuring the embed is positioned within this section.

Moreover, by assigning position and z-index attributes to the elements, such as the heading, paragraph, and track, the interaction can be seamlessly integrated, with the text scrolling out of the way as the embed remains sticky within the track.

Once these adjustments are made, the project can be published to validate the seamless integration and smooth functionality of the 3D scroll interaction in Webflow.

Conclusion

In conclusion, creating a captivating 3D scroll interaction using Webflow and Spline involves a series of meticulous steps, encompassing the design and animation aspects in Spline before seamlessly integrating the exported animation into Webflow with the added functionality of sticky behavior. By following the detailed steps outlined in this tutorial, users can effectively create and integrate engaging 3D scroll interactions to enhance the visual appeal and user experience of their web projects.