Skip to content

Navigation arrows behavior #443

Answered by NaotoshiFujita
ejdzipi asked this question in Q&A
Discussion options

You must be logged in to vote

Splide does not support such behavior by default, but you can achieve that with events, visible and hidden.

const splide = new Splide( ... );
const { Components } = splide;

splide.on( 'visible', Slide => {
  // When the first slide gets visible in the viewport:
  if ( Slide.index === 0 ) {
    Components.Arrows.arrows.prev.disabled = true;
  }
} );

splide.on( 'hidden', Slide => {
  // When the first slide gets hidden from the viewport:
  if ( Slide.index === 0 ) {
    Components.Arrows.arrows.prev.disabled = false;
  }
} );

splide.mount();

You can check the last slide by splide.length - 1 in the same way.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ejdzipi
Comment options

Answer selected by NaotoshiFujita
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants