As far as I can tell Webflow does not support this natively, so I wrote a custom script to do it. I have made a demo site showing how I did this here and you can clone the project here.
If you clone this and use it for yourself there are a few things to note:
The custom code lives at the CMS page level in here:
The script references data-tags on various elements that look like this:
Current limitations:
I did not code an option for infinite scroll.
The animation is hard coded to be transform 500ms ease 0s as this is the Webflow default. I can’t read it on the fly from the page so at this stage you are stuck with whatever you hard code in the script.
Script (for anyone who can’t see it after they clone the project)
Hey there @jasondark Thank you so much for this, but the script is missing from your demo site, please can you add the scrip back in or past it here pretty please? Much appreciated
Hi @jasondark, thank you so much for adding this! Very helpful.
I’ve added everything as described, custom code, elements and all. It seems everything executes except the only thing I can get the slider to do is have a grey box slide back and forth with no images.
It does look like the script is executing somewhat, but it seems the images aren’t being placed correctly into the slider - just grey boxes. Idk, that’s my best guess.
Hey @jasondark , ditto on the no before body tag within the clone. I’m pasting from Viewing page Source.
I’m still not seeing it work after pasting however. My console isn’t showing any error but still only getting three grey boxes. What is notable is that there are 3 pictures in the ‘More Images’ field of the CMS, so the script is executing that piece, the phots just aren’t appearing where the grey boxes are. Have tried everything.
Thanks again for your help, hate being a pest - but would love to utilize what you’re sharing here, WebFlow needs to catch up!
Thanks for letting me know, I have edited my original post to include the script.
It’s not feasible for me to troubleshoot everyone’s custom code issues. What I would say is that this script relies on the data attributes being set correctly on the Webflow elements. So double check that;
Your slider has all the data attributes set (they look like this in the script [data-cms="image"])
Somewhere on your page, there exists the hidden CMS collection with your CMS images, each with the correct data attribute set.
@jasondark This is amazing! It’s saved me so much hassle.
I thought I would flag a bug when using this script incase someone else comes across a solution (as I’m not that confident with JavaScript). The slider seems to cycle through all the slides with bg images and for some reason when the slider gets to the last slide with a bg image the slider continues to cycle through the slides without bg images. If you click on the right arrow it will return to the first slide with a bg image.
Hope that makes sense and again thank you for writing the this script.
Just one question - I’m using it for e-commerce products, when selecting a different option of a product (for example a different colour) it doesn’t find the matching images. I can’t think of a way I can connect product variations. Do you know a fix for this?
I got this to work but am not sure where I would go about changing the background image to cover the slide container (scale to fit the parent). Would you know if this is something I could fix in the CSS?
Edit: Was actually able to fix in the normal slider settings! I didn’t realize it would still adopt the bg image settings even through it wasn’t pulling the image from there.
Hi @jasondark,
Thanks for setting this up your code works perfect. Howerer I stumble up on 1 thing. the amount of slider to display is not being handled correct correctly on Chrome but it does on safari.
Example: https://lanssens.webflow.io/materiaal/solid-color
Open the above in safari and chrome. In safari you will see there are only 5 slides (because 5 items in the CMS) in chrome however are all slides shown.