Settings aren't working correctly for breakpoints
See original GitHub issueFirst of all I want to say that I am very happy with Glide.js! I noticed a bug (I think) though when it comes to defining breakpoints.
const glide = new Glide('.glide', {
type: 'slider',
perView: 3,
bound: true,
gap: 10,
dragThreshold: false,
breakpoints: {
1024: {
startAt: 0,
perView: 2,
dragThreshold: 120,
},
600: {
startAt: 0,
perView: 1,
dragThreshold: 120,
}
},
});
glide.mount();
I have a slider with 3 items, which I want to show next to each other. The dragThreshold is set to false, so that it is not possible to navigate. But when the screen is getting smaller I want the enable the dragThreshold (when it fires the breakpoint). But this doesn’t work, as you can see in my pen: https://codepen.io/jfrdfr/pen/QXwNNj
I also noticed that the ‘startAt’ option is not working for breakpoints. When I am navigating the elements on a smaller device (for example when perView is set to 1), but when it hits another breakpoint it doesn’t reset the slide back to the 0 index.
I hope you could help me out with this! Maybe I am using it wrong (or expecting wrong results).
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Hey guys, sorry to bump. But I was having this issue and solved it for myself, so you (or any future readers) may have overlooked the same thing I did.
At the very bottom of this page, the docs remind you to pull in all modules that you need – not just
Glide
. So I had forgotten both, { Breakpoints }
in my import and{ Breakpoints }
in themount()
call at the end.Sorry for the late reply, I have tried the latest version (3.4.1) and sadly it doesn’t work as I expect it to. I’m currently using Firefox 77.0.1 on Windows. I’ve made a new pen to showcase my issue: https://codepen.io/Afgedankt/pen/vYLgKgP
dragThreshold: The slider I was using had three slides. On desktop I wanted to disable the threshold, so that the visitor can’t move the slides (in a way that is disabling the slider). When resizing the browser it will eventually show two slides, but sadly the threshold is still disabled, even though I specified it in the breakpoint. This also happens the other way around: when the two slides are visible (threshold is then enabled) and resize it until I see three slides again, the threshold isn’t disabled.
startAt Almost the same behaviour exists for this option. I’m expecting that when I hit a new breakpoint the slider resets back to the first slide.
Again, maybe I’m using this wrong. It does look like when a breakpoint is hit not all the options are processed in the slider.
Hope I made myself more clear! Anyway, still enjoying the plugin 😃 Hope this issue will get fixed, so that I can use it for more projects!