Image Carousel slides to scroll in mobile
Description
This is both an issue and kind of a feature request:
When adding an image carousel to a page, you can select the amount of slides to show and slides to scroll. The slides to show allows responsive options, the slides to scroll does not. In mobile, slides to scroll defaults to 1, regardless of the value in the dashboard. Put in 2, it scrolls 1 on mobile. Put in 5, it scrolls 1 on mobile.
It would be nice if the slides to scroll value was respected for mobile, or to be able to have responsive options for slides to scroll.
Thanks!
Currently, this feature is not supported, but we will look into it in the future if we see a large demand for it.
Thanks for the feedback.
You closed this because there "isn't large demand"?
It's a bug in a PAID plugin...
You allow someone to select a number of slides to scroll, then change that number regardless of user's settings. And that's normal behavior and not an issue? Makes sense to me...
I think this should be reopened and I think @bainternet did not realize this is definitely a logic issue with the options presented.
For example, let's say I have a carousel slider that shows 6 images desktop, 4 tablet and 3 mobile. Currently I can set the responsive slide count but I cannot set the responsive number of images to slide.
By default it slides 1 image at a time, so in desktop 1 image scrolls out of view and disappears while another image slide into view. No issues with other media queries when we drop to 4 or even 3.
However, if I set my slide count to 6, in desktop mode, all 6 images slide out of view and 6 new ones slide in. When viewed on tablet and mobile, there is no responsive options to tell it only slide 4 for tablet and then 3 mobile...it will still slide 6 images!!!
This is not a small demand feature request.

I would also definitely want this issue fixed. When it scrolls 3 slides on desktop you can also set to show 3 slides but you can't set 1 slide to scroll on mobiles and it still slidss 3 per scroll. It should be fixed.
Hey guys, the way I went around this was to write my own slick sliders. The slick library is included in E, so it was just learning the syntax to add settings and create my own in jQuery. Hardly a solution to this issue, but when the issue is ignored, you find your own way.
While they think this is a feature and not a bug, I created a quick script to fix it on mobiles. I just used html widget for this:
<script>
jQuery(document).ready(function($){
if ( $(window).width() < 767 ) {
$( ".elementor-element-c598e7c" ).data( "settings" ).slides_to_scroll = 1;
}
});
</script>
where .elementor-element-c598e7c is your own unique class for carousel slider. That worked for me.
@viktarbel I can't get your script to work for slides_to_scroll = 3. By default tablet and mobile could only scroll 1 slide at once, no matter what setting I put. It seems that the setting is only for desktop.
@2amredart When I created a carousel slider I set slides to scroll=3 in the elementor settings so on desktop it slides 3 images per scroll. But when I checked this on mobiles then it also slides 3 images per scroll even if I see only 1 image. Pretty ugly, huh? So when I used that script above I changed option "slides to scroll" from 3 to 1 on mobiles so it looks okay. So it should work for you too if you want to change this option for mobiles to 3 (if you set 1 for desktop for example).
@viktarbel I am using Astra child theme and Elementor plugin latest version.
Carousel 6c511a0 with slides to scroll=1.
<div data-id="6c511a0" class="elementor-element elementor-element-6c511a0 elementor-widget elementor-widget-image-carousel" data-settings="{"slides_to_show":"7","slides_to_scroll":"1","navigation":"arrows","slides_to_show_tablet":"5","slides_to_show_mobile":"3","pause_on_hover":"yes","autoplay":"yes","autoplay_speed":5000,"infinite":"yes","speed":500,"direction":"ltr"}" data-element_type="image-carousel.default">
Carousel 49a0f39 with slides to scroll=3.
<div data-id="49a0f39" class="elementor-element elementor-element-49a0f39 elementor-widget elementor-widget-image-carousel" data-settings="{"slides_to_show":"7","slides_to_show_tablet":"5","slides_to_show_mobile":"3","slides_to_scroll":"3","navigation":"arrows","autoplay_speed":2500,"speed":250,"pause_on_hover":"yes","autoplay":"yes","infinite":"yes","direction":"ltr"}" data-element_type="image-carousel.default">
Added this twice to my child theme footer.php (the last script loaded) and body of my homepage.
<script>
jQuery(document).ready(function($){
$( ".elementor-element-6c511a0" ).atr( "settings", { "slides_to_scroll": "3"});
});
</script>
</body>
</html>
Sorry I tried the below codes first, it didn't work and I tried other codes as well
<script>
jQuery(document).ready(function($){
$( ".elementor-element-6c511a0" ).data( "settings" ).slides_to_scroll = 3;
});
</script>
</body>
</html>
After that on mobile it's still only scrolling 1 slide for both carousel.
Nothing seems to make it 3 slides per scroll on mobile.
I have total 7 images.
Not sure whether it's relevant but on view source " is showing as "
It shouldn't be $quot; instead of " Try to copy script to the text editor like notepad++, replace all quotes with new quotes and then paste it to your site. You can post url here as well.
@viktarbel If you view via F12, it's alright. If you view via Ctrl+U, the format is just off. The URL is https://comparepremium.sg/
@2amredart First of all you have a jquery error on the site. I believe this is because you define jquery in the footer and one of the script you use is above the footer - on the page. You don't need 2 identical scripts.
So try to either define jquery in the header (maybe your theme allows this) and remove unnecessary script in the footer or remove script that you used in the elementor widget and leave the one in the footer.
@viktarbel Yeap, I've just removed the html widget script. I actually started with the same solution as yours except slides to scroll = 3. Nothing seems to work and finally I put the script in the footer, thinking its because the jQuery library called out at the bottom. I've even removed the window width to force it on all screen size.
@2amredart Try to use some delay on our script using setTimeout function: https://www.w3schools.com/jsref/met_win_settimeout.asp
That's weird why it doesn't work.
p.s. in the elementor settings did you set "slides to scroll" to 1 or is it set to "default"? If it's default then try to set it to 1 and then set on mobiles to 3.
@viktarbel I've done it, is this correct? I've also tested it, it's the same result.
<script>
jQuery(document).ready(function($){
var myVar;
myVar = setTimeout(alertFunc, 3000);
});
function alertFunc() {
$( ".elementor-element-6c511a0" ).data( "settings" ).slides_to_scroll = 3;
}
</script>
</body>
</html>
Did you mean "Slides to Show", if so all of them are not default. I've changed the settings a lot of times. If you mean "Slides to Scroll", there is no option to change between devices. I am on Elementor free version, is that why it didn't work?
Even the modified script which is suppose to affect all screen size including desktop didn't work. Could you send me your url that worked? I could also compare.
It's night here, so I have sleep.
@2amredart No, I did mean "Slides to Scroll". I know that there is no option to change between devices but did you changed it from default to 1?
You could make it easier like this:
<script>
jQuery(document).ready(function($){
setTimeout(function(){
$( ".elementor-element-6c511a0" ).data( "settings" ).slides_to_scroll = 3;
}, 500);
});
</script>
Timeout function is just an option that helped me sometime. Maybe it's not helpful here. But please use "if" statement for mobiles in the script like in my original post, maybe it does matter in this case. If you use browser to check how it looks on mobiles then you need to refresh the page when you made screen width like mobile screen.
And pay attention to the console log because you have a js error again.
And yes, I used premium version of Elementor but I don't think it's because of this. Try different settings for "Slides to Scroll" like change it to 3 and then check how it scrolls on desktop and mobiles then change to 1 via script, etc.
My url is https://uavcoach dot com/drone-training/
@viktarbel Yeap, I've changed it from default to 1 and other numbers. I've also changed it to your codes. I used the codes for all screen sizes because I want to narrow down what went wrong. I don't know but your codes should work no matter what screen. The issue could be somewhere else that we don't know.
I've check console this time only have this message
JQMIGRATE: Migrate is installed, version 1.4.1
[Violation] Forced reflow while executing JavaScript took 30ms
[Violation] Forced reflow while executing JavaScript took 39ms
I actually used your codes for Livemesh Addons for Elementor. But it still did not work. There the issue I have was the plugin limits the column per row to 5. Actually I need 7 or more maybe in the future. Here is the link to their support where I am hope they could change this in their plugin because I actually change their plugin codes to make the columns per row more than 5.
<script>
jQuery(document).ready(function($){
setTimeout(function(){
$( ".elementor-element-6c511a0" ).data( "settings" ).slides_to_scroll = 3;
}, 500);
$( ".elementor-element-6c511a0" ).data( "settings" ).slides_to_scroll = 3;
$( ".elementor-element-6c511a0" ).data( "settings" ).slides_to_show = 3;
$( ".elementor-element-49a0f39" ).data( "settings" ).slides_to_scroll = 3;
$( ".lae-carousel" ).data( "settings" ).display_columns = 7;
$( ".lae-carousel" ).data( "settings" ).arrows = false;
});
</script>
</body>
</html>
@joshmarom fyi, I see this was referenced in the past 2.1 update but didn't seem to make the cut?
I tried the code above, even though I have my carousel set to scroll 4 items, in tablet and mobile it only scrolls 1 item.
Inspecting the sliders data-settings attribute, even in mobile widths the setting "slides_to_scroll":"4" is still present so I don't think the code snippets above are doing anything but replacing what is already there. The setting remains "4" yet the slider code seems to be strict about only sliding 1 item below a certain width.
if ( $(window).width() < 1024 ) {
$( "elementor-element-0b648c4" ).data( "settings" ).slides_to_scroll = 4;
}
Preferentially it'd be great if we could set a value per device width just the same as "Slides per view" as I detailed above in my first response.
FYI, here's what I see attached to my slide element for data-settings attribute:
{"slides_to_show":"4","slides_to_show_tablet":"4","slides_to_show_mobile":"4","slides_to_scroll":"4","navigation":"arrows","pause_on_hover":"yes","autoplay":"yes","autoplay_speed":5000,"infinite":"yes","speed":500,"direction":"ltr"}
I could not get el.slickGetOption or el.slickSetOption to work even though I see prototype.slickGetOption and prototype.slickSetOption in the slick.min.js and my script is literally the last script loading on the page using wp_enqueue_script method w/ array('jquery','jquery-slick','elementor-frontend','elementor-pro-frontend') dependencies. First I tried to get the setting:
var respObj = $( '.elementor-element-0b648c4' ).slickGetOption( 'responsive' );
console.log(respObj);
Expecting to see the default "responsive" object but instead I get an Uncaught TypeError: "slickGetOption is not a function"
So I try:
var respObj = $( '.elementor-element-0b648c4' ).slick( 'slickGetOption', 'responsive' );
console.log(respObj);
I then get another Uncaught TypeError: "Cannot read property 'slickGetOption' of undefined"
I also tried to force some overrides:
$( '.elementor-element-0b648c4' ).slickSetOption( 'responsive', [{
breakpoint: 1025,
settings: {
slidesToScroll: 4
}
},{
breakpoint: 768,
settings: {
slidesToScroll: 4
}
}]
);
and...
$( '.elementor-element-0b648c4' ).slick( 'slickSetOption', 'responsive', [{
breakpoint: 1025,
settings: {
slidesToScroll: 4
}
},{
breakpoint: 768,
settings: {
slidesToScroll: 4
}
}]
);
Maybe this is a bug with the slick slider plugin using those GET and SET commands but I can see slick object when using console.log( el.slick ).
For now, I've had to hard edit frontend.js:L:1217-1240 where slidesToScroll is forced default at 1 and I needed 4 modified the 2 lines below for each breakpoint:
var slickOptions = {
slidesToShow: slidesToShow,
autoplay: 'yes' === elementSettings.autoplay,
autoplaySpeed: elementSettings.autoplay_speed,
infinite: 'yes' === elementSettings.infinite,
pauseOnHover: 'yes' === elementSettings.pause_on_hover,
speed: elementSettings.speed,
arrows: -1 !== ['arrows', 'both'].indexOf(elementSettings.navigation),
dots: -1 !== ['dots', 'both'].indexOf(elementSettings.navigation),
rtl: 'rtl' === elementSettings.direction,
responsive: [{
breakpoint: breakpoints.lg,
settings: {
slidesToShow: +elementSettings.slides_to_show_tablet || (isSingleSlide ? 1 : 2),
slidesToScroll: 4
}
}, {
breakpoint: breakpoints.md,
settings: {
slidesToShow: +elementSettings.slides_to_show_mobile || 1,
slidesToScroll: 4
}
}]
};