Fix: Add logic to reset autoplay and autoscroll on carousel interaction#164
Open
milindmore22 wants to merge 3 commits into
Open
Fix: Add logic to reset autoplay and autoscroll on carousel interaction#164milindmore22 wants to merge 3 commits into
milindmore22 wants to merge 3 commits into
Conversation
…n carousel interaction
Contributor
There was a problem hiding this comment.
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
stopPluginsOnInteractionutility to centralize stop/reset logic forautoplayandautoScroll. - Updated
scrollPrev,scrollNext, andscrollToSnapactions 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 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() }; |
…est cleanup with try-finally blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
stopPluginsOnInteractionutility to centralize logic for stopping or resetting theautoplayandautoScrollplugins based on thestopOnInteractionconfiguration in the carousel context.scrollPrev,scrollNext, andscrollToSnapactions to invokestopPluginsOnInteractionbefore scrolling, ensuring consistent plugin behavior on user interaction. [1] [2] [3]Testing improvements:
autoplayandautoScrollplugins are properly stopped (destroyed) or reset when the user interacts with carousel controls, depending on thestopOnInteractionsetting.Type of change
Related issue(s)
Closes #163
What changed
Interaction and Stopandon Mouse Hoverare enabled the User is now able to interact with Next and previous buttons and carousel dots and stop autoscrollStop on Interactionis enabled, If user click on Next previous button or interact with slides it stops autoscrollon Mouse Hoveris 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.
Testing
Describe how this was tested.
Test details:
Screenshots / recordings
If applicable, add screenshots or short recordings.
Checklist