Skip to content

Cannot trigger autoplay based on overflow #1370

@kiwimind

Description

@kiwimind

Checks

Version

v4.1.4

Description

I have multiple, working slides on a page.

What I'm trying to achieve is allowing slides to loop and autoplay when there are enough slides to do so.

According to the docs, something like this should probably work, as I'm able to control other options based on isOveflow:

slides.on('overflow', function(isOverflow) {
  slides.go(0);
  slides.options = {
    clones: isOverflow ? undefined : 0,
    autoplay: true,
  }
});

The clones option is working as expected, and if I put another option in there like gap and amend it based on isOverFlow then it works fine, even with a single value, proving that the function is working as expected.

I don't know why autoplay isn't controllable in here, as it seems I'm needing to enable it in the main options list, which means that when there are not enough slides to fill the track, it still autoplays, even though the clones are not present.

Other relevant options:

  type: 'loop',
  gap: '1.5rem',
  pagination: false,
  autoWidth: true,
  arrows: false,
  interval: 4000,
  speed: 4000,
  perMove: 1,
  easing: 'linear',

Reproduction Link

No response

Steps to Reproduce

  1. Create carousel with enough slides to overflow, then another that does not
  2. Implement the on overflow function and try to control autoplay only when overflow is true

Expected Behaviour

Slides should only autoplay when there are enough to overflow. Currently it does not seem like we can trigger autoplay based on overflow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions