Skip to content

Introduced new swipeStart, swipeMove, swipeEnd event#4341

Open
Arifursdev wants to merge 2 commits into
kenwheeler:masterfrom
Arifursdev:master
Open

Introduced new swipeStart, swipeMove, swipeEnd event#4341
Arifursdev wants to merge 2 commits into
kenwheeler:masterfrom
Arifursdev:master

Conversation

@Arifursdev

@Arifursdev Arifursdev commented Oct 5, 2025

Copy link
Copy Markdown

This pull request introduces new swipe-related events to the Slick slider, allowing developers to hook into the swipe lifecycle more easily. The changes include both documentation updates and event triggers in the code.

New Swipe Event Support

  • Added new event triggers:
    • swipeStart – fired when a swipe begins
    • swipeMove – fired while the swipe is in progress
    • swipeEnd – fired when the swipe ends

Example Use Case

These new swipe events can help address common issues, such as preventing click events from firing while dragging a slide.

Scenario

Imagine a carousel section containing videos. Without proper swipe handling, after a swipe ends, if the mouse is over a video element, it may trigger a click and start playback unintentionally.

Implementation

$('[sample-section-wrap="items"]:not(.slick-initialized)').each(function () {
  $(this).slick({
    slidesToShow: 4,
    slidesToScroll: 1,
    swipeToSlide: true
    // ...
  })
  .on('afterChange', (event, slick, currentSlide) => {
    setTimeout(() => {
      $(this).removeClass('slick--is-moving');
    }, 100);
  })
  .on('swipeStart', () => {
    $(this).addClass('slick--is-moving');
  })
  .on('swipeEnd', () => {
    setTimeout(() => {
      $(this).removeClass('slick--is-moving');
    }, 100);
  });
});
.slick--is-moving {
  video {
    pointer-events: none;
  }
}

@markvantilburg markvantilburg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmadalfy can you merge this? (i cannot edit this pull to remove the .min.js)

@Arifursdev Arifursdev left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes swipeMove event so it triggers when carousel actually moves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants