How To

Dance of the Dots: Choreographing Custom Slider Controls in Webflow

Dance of the Dots: Choreographing Custom Slider Controls in Webflow
August 21, 2024

  · 6 min

Dive into the realms of jQuery to create custom slider controls in Webflow. A step-by-step guide to orchestrating an interactive dance between your design elements and user interactions!

Hey, Webflow designers. Today, we're venturing into the juicy world of jQuery and custom slider controls. Yes, we’re about to make those static dots under your Webflow slider dance to your tune. We recently had a project where we needed to control the Webflow slider using linkblocks outside the Webflow slider element. (Long story short we have an overlay nav element with a bunch of linkblocks that needed to take you to specific slides when you clicked on them). Below’s a short video showing our custom controls:

<div style="padding:81.1% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/873388654?badge=0&amp;autopause=0&amp;quality_selector=1&amp;progress_bar=1&amp;player_id=0&amp;app_id=58479" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" style="position:absolute;top:0;left:0;width:100%;height:100%;" title="Custom Slider Controls in Webflow"></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>

Anyhow, we Googled a bunch, figured out we could trigger a change to a specific slide by simulating a click on that slide’s navigation dot and cobbled together a script to do that). Lets kick off by giving you the script you’re gonna need for this:

<iframe height="300" style="width: 100%;" scrolling="no" title="Custom Slider Controls" src="https://codepen.io/milkmoonstudio/embed/preview/rNoRzNG?default-tab=html" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
See the Pen <a href="https://codepen.io/milkmoonstudio/pen/rNoRzNG">
Custom Slider Controls</a> by Jakes van Eeden (<a href="https://codepen.io/milkmoonstudio">@milkmoonstudio</a>)
on <a href="https://codepen.io">CodePen</a>.
</iframe>

Prelude to the Dance: What You'll Need

Before we dive into the code ocean, ensure you have the following ready:

  • A Webflow project where you want to implement the custom slider controls. Classes on the slider don’t matter much, we’re calling the native slider not names in Webflow in the script: .w-slider-dot
    We don’t even have them visible in our project, element visibility was set to hidden.
  • A very basic understanding of jQuery (fear not, we’ll walk through it).

Act 1: Preparing the Stage

First thing’s first, let’s ensure our Webflow project is prepped and primed for some jQuery action.

Creating the Slider:

  1. Navigate to your Webflow Designer.
  2. Create a new slider element.
  3. Customize it to your heart’s content but leave the dots below the slider as they are, or hide them.

Custom Dot Creation:

  1. Create a new div block and name it controls__wrap.
  2. Now, within controls__wrap, create your link blocks (one for each slide in your slider) and give each a class of slider__controller.
  3. Style these link blocks as you wish - these are your controls that will take you to each slide in your slider,  their order corresponds to the order of your slides.

Act 2: The jQuery Ballet

Now, onto the code that will make those dots dance! We’re going to use jQuery to create a lively interaction between our custom dots and the Webflow native slider dots.

Code Pen Preparation:

  1. Head to your project settings or page settings.
  2. Under the ‘Custom Code’ tab, you’ll find a haven for your custom scripts in the ‘Footer Code’ section. This is where our jQuery script will reside.

Pasting the Script:

  1. Copy the script we shared earlier.
  2. Paste it into the ‘Footer Code’ section of your project settings.

Understanding the Magic:

The script loops through each custom dot within .controls__wrap, and when a custom dot is clicked, it triggers a tap event on the corresponding native Webflow slider dot, navigating to the respective slide.

Act 3: Curtains Close, Applause Ensues

Now, head back to the Designer, hit publish, and behold the dance of the dots on your live site! Your custom dots should now control the Webflow slider, providing a tailored experience for your audience.

We hope this helps you as much as it helps us, I’m not sure who came up with the idea to control the dots, we just found a reference and a snippet of the code on Stackoverflow and then fleshed it out from there, but it’s neat, so enjoy.

Share

All Posts

Gradient Background