question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The Slider is skipping other items

See original GitHub issue

Hello, when users swipe hard enough it looks like its skipping other slides, how can we limit it to only one slide per swipe? slidesToScroll: 1 doesn’t seem to do anything

const wrap = document.querySelector('.js-home-slider');
  const viewPort = wrap.querySelector('.js-home-slider-viewport');
  const dots = wrap.querySelector('.js-home-slider-dots');
  const homesliderStart = EmblaCarousel(viewPort, {
    loop: true,
    draggable: true,
    dragFree: false,
    speed: 10,
    startIndex: 0,
    slidesToScroll: 1,
  });

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:33 (19 by maintainers)

github_iconTop GitHub Comments

4reactions
davidjerlekecommented, Dec 24, 2019

Hello @leah-cc, Thank you for your question 👍.

The short answer is:

That this is by design and it’s intended to work this way.

The long answer is:

That the Embla Carousel animation engine is different from other carousel plugins. It animates by simulating physics and I made this design choice because I wanted a carousel that feels natural to drag and interact with. If I were to limit swipe gestures to progress only one slide, no matter how vigorous the swipe gesture was, that would make the movement arbitrary as opposed to natural, and would go against the very core of how Embla works.

Most available carousel plugins only determine which direction the carousel was dragged and decide whether the carousel should move to the next or the previous slide. If you think about it, this behavior is very unnatural. Because if you were to drag something in real life with a lot of force, it would move further away than if you were to drag it with less force. So Embla not only determines which direction the carousel was dragged, it also measures the drag force. Based on the drag force it will or will not skip slides. It all depends how hard the users drag it.

We have a new browser standard emerging for horizontal (and vertical) scroll areas on websites called CSS scroll snaps, and they also work this way. If you’re interested, take a look at this CSS scroll snap example and try dragging it on mobile. I decided to go with the same drag design choice for Embla Carousel. I hope I’ve managed to explain why I made this choice and that all of this makes sense to you.

Kindly, David

3reactions
davidjerlekecommented, Apr 22, 2021

@jeiea this feature has just been released with v4.5.0. Thank you for taking time to test this out.

Enjoy, David

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this <input type="range> slider skipping the first 10 of ...
The problem is that you're not adding all the needed zeroes. When the slider value is 7 , the selector will be #day07...
Read more >
asNavFor skipping certain items · Issue #1416 · akiran/react ...
I'm using the asNavFor variable to make 2 sliders move together while sliding. the first slider is the navigation showing 3 items and...
Read more >
How to Stop Powerpoint From Skipping Slides
2. Click on the "View" tab and choose "Slide Sorter." Look at the thumbnails of the slides in your presentation. If any of...
Read more >
PowerPoint skipping slides - Microsoft Community
Open your PowerPoint file with the skipping slides. Click on the View tab and select Slide Sorter. Look at the thumbnails of the...
Read more >
Nobody Uses Sliders: 5 Reasons to Skip the Slider on your ...
Banner blindness is the term used to describe a certain well known behaviour whereby potential customers scroll past items on a page that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found