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.

Create an option to block excessive scrolling

See original GitHub issue

Hi @davidjerleke!

Embla currently has ways to remove the leading and trailing blanks from the Slider (containsScroll: true), but still allow for excessive scrolling. It would be interesting to add an option to block this scroll and stop it when it reaches the end or beginning of the Slider. I would like to know what you think of this idea

Below is the example of the “excessive scroll” I am referring to

Captura de Tela (21)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
davidjerlekecommented, Aug 10, 2021

Hi @joeyvanlierop, @jeiea,

To anyone wanting to block excessive scrolling: You can use the following code snippet:

const embla = EmblaCarousel(emblaNode, { skipSnaps: false });

const preventEdgeScrolling = (embla) => {
  const { limit, target, location, scrollTo } = embla.dangerouslyGetEngine();

  return () => {
    if (limit.reachedMax(target.get())) {
      if (limit.reachedMax(location.get())) location.set(limit.max);
      target.set(limit.max);
      scrollTo.distance(0, false);
    }
    if (limit.reachedMin(target.get())) {
      if (limit.reachedMin(location.get())) location.set(limit.min);
      target.set(limit.min);
      scrollTo.distance(0, false);
    }
  };
};

embla.on("scroll", preventEdgeScrolling(embla));

Cheers, David

3reactions
davidjerlekecommented, Nov 7, 2020

Hello Laks (@LaksCastro) and Joey (@joeyvanlierop)!

Thank you for your question Joey. The answer to your question is no, not yet. But I’ve quite recently added this to my list of things to investigate, together with issue #38, because it seems like these issues are getting a bit of traction. Please note that I can’t promise any outcome but I will at least look into it further.

I can’t give an ETA for this though. Public feature requests are progressing quite slow right now due to lack of time.

I hope you understand.

Best, David

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create an option to block excessive scrolling #42 - GitHub
Hi @davidjerleke! Embla currently has ways to remove the leading and trailing blanks from the Slider (containsScroll: true), but still allow ...
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
Read more >
Prevent "overscrolling" of web page - Stack Overflow
This solution doesn't work as of Chrome 46 for Mac. It prevents over-scrolling but none of the child elements are scrollable. – Daniel...
Read more >
How Scrolling Can Make (Or Break) Your User Experience
Cater Your Content. The first way to encourage scrolling is to design your content so it is easy to scroll through. Consider these...
Read more >
How to Stop Doomscrolling News and Social Media
What can we do to prevent ourselves from endlessly scrolling? ... writing cards and letters as an alternative activity during the pandemic.
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