Skip to content

Fix: Add logic to reset autoplay and autoscroll on carousel interaction#164

Open
milindmore22 wants to merge 3 commits into
developfrom
fix/autoscroll-interaction
Open

Fix: Add logic to reset autoplay and autoscroll on carousel interaction#164
milindmore22 wants to merge 3 commits into
developfrom
fix/autoscroll-interaction

Conversation

@milindmore22

Copy link
Copy Markdown
Contributor

Summary

This pull request enhances the carousel's behavior by improving how autoplay and autoscroll plugins respond to user interactions, and adds comprehensive tests to verify these behaviors. The main focus is to ensure that, depending on configuration, the carousel either stops or resets these plugins when users interact with navigation controls.

Carousel plugin interaction handling:

  • Added the stopPluginsOnInteraction utility to centralize logic for stopping or resetting the autoplay and autoScroll plugins based on the stopOnInteraction configuration in the carousel context.
  • Updated the carousel's scrollPrev, scrollNext, and scrollToSnap actions to invoke stopPluginsOnInteraction before scrolling, ensuring consistent plugin behavior on user interaction. [1] [2] [3]

Testing improvements:

  • Added new tests to verify that autoplay and autoScroll plugins are properly stopped (destroyed) or reset when the user interacts with carousel controls, depending on the stopOnInteraction setting.

Type of change

  • Bug fix
  • New feature
  • Enhancement/refactor
  • Documentation update
  • Test update
  • Build/CI/tooling

Related issue(s)

Closes #163

What changed

  • When both Stop on Interaction and Stop and on Mouse Hover are enabled the User is now able to interact with Next and previous buttons and carousel dots and stop autoscroll
  • When Just Stop on Interaction is enabled, If user click on Next previous button or interact with slides it stops autoscroll
  • When Just on Mouse Hover is enabled and if user hover on slides it stops the slide and On mouse out it continue with autoscroll effect.

Breaking changes

Does this introduce a breaking change? If yes, describe the impact and migration path below.

  • Yes — migration path:
  • No

Testing

Describe how this was tested.

  • Unit tests
  • Manual testing
  • Cross-browser testing (if UI changes)

Test details:

Screenshots / recordings

If applicable, add screenshots or short recordings.

Checklist

  • I have self-reviewed this PR
  • I have added/updated tests where needed
  • I have updated docs where needed
  • I have checked for breaking changes

Copilot AI review requested due to automatic review settings July 10, 2026 10:39

Copilot AI 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.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Enhances carousel interaction handling so autoplay and autoScroll plugins are consistently stopped or reset when users use navigation controls, and adds tests to validate the behavior.

Changes:

  • Added stopPluginsOnInteraction utility to centralize stop/reset logic for autoplay and autoScroll.
  • Updated scrollPrev, scrollNext, and scrollToSnap actions to invoke the utility before scrolling.
  • Added Jest tests for stop vs reset behavior based on stopOnInteraction.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/blocks/carousel/view.ts Centralizes plugin stop/reset behavior and wires it into scroll actions.
src/blocks/carousel/tests/view.test.ts Adds tests verifying plugin stop/reset behavior on interaction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/blocks/carousel/view.ts Outdated
Comment thread src/blocks/carousel/__tests__/view.test.ts
Comment thread src/blocks/carousel/view.ts
Copilot AI review requested due to automatic review settings July 10, 2026 11:19

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread src/blocks/carousel/view.ts Outdated
Comment thread src/blocks/carousel/__tests__/view.test.ts Outdated
Comment on lines +263 to +264
const mockAutoplay = { stop: jest.fn(), destroy: jest.fn(), reset: jest.fn() };
const mockAutoScroll = { stop: jest.fn(), destroy: jest.fn(), reset: jest.fn() };
@milindmore22 milindmore22 requested review from Copilot and removed request for Copilot July 10, 2026 12:03
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.

[Bug]: Auto Scroll functionality on user interaction.

2 participants