feat: [FIND-7602] Enhanced slide transition to work for multiple slides#91
Conversation
4e965f1 to
f645320
Compare
|
@ali2-godaddy : Can you please include some screenshots/recordings of the change? |
There was a problem hiding this comment.
Pull request overview
This PR enhances the carousel's slide transition logic to properly handle multi-slide transitions in infinite scroll mode, particularly when looping around the carousel boundaries. The changes fix a bug where the goToSlide function would incorrectly calculate offsets when looping left, and enforce the use of the direction argument for proper animation behavior.
Changes:
- Fixed offset calculation in
calcLeftOffsetto detect and handle looping transitions - Added logic to use clone slides for smooth wrapping animations
- Refactored code formatting and style consistency throughout the codebase
- Enhanced test setup to mock viewport dimensions for more accurate testing
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/carousel.tests.js | Removed old test file (renamed to .test.jsx) |
| test/unit/carousel.test.jsx | Renamed from .tests.js with added tests for calcLeftOffset scenarios including looping transitions |
| test/setup.js | Added jsdom mocks for offsetWidth and offsetHeight to enable viewport testing |
| src/stories/CustomArrows.js | Fixed missing semicolon |
| src/index.js | Enhanced calcLeftOffset with looping detection logic, formatted code, and updated stopDragging to set transitioningFrom |
| package.json | Updated test commands and added jsdom-testing-mocks dependency |
| .mocharc.json | Added mocha configuration file with test setup requirements |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@ali2-godaddy : Was wondering if we can make the card height of the cards in the carousal the same ? |
a668850 to
11a2292
Compare
This can be configured by setting the slideHeight prop. |
65d93f4 to
709dfbf
Compare
jsanthosh-godaddy
left a comment
There was a problem hiding this comment.
LGTM, Please get approval from Chris as well.
vitest.config.js
Outdated
| environment: 'happy-dom', | ||
| setupFiles: './test/setup.js', | ||
| include: ['test/**/*.tests.{js,jsx}'], | ||
| include: ['test/**/*.test.{js,jsx}'], |
There was a problem hiding this comment.
Good point, addressed
There was a problem hiding this comment.
Hi @ali2-godaddy — I noticed this package-lock.json change points the registry back to Artifactory. Since this package is open source, public consumers won’t be able to install it if the lockfile references Artifactory.
Could we reset the lockfile to main and re-apply the updates using npm as the registry?
Steps that should work:
-
git reset origin/main package-lock.json -
Temporarily use the public npm registry (without changing your global config):
npm install --registry=https://registry.npmjs.org/ --package-lock-only
-
Voilà. Now you can check in the updated package-lock.json, which should reference npm as the registry.
This shouldn’t change anything for internal consumers — running npm internally will still use Artifactory as the configured registry, which proxies and caches npmjs automatically.
There was a problem hiding this comment.
BTW—This is probably the only comment of mine that should block anything, because if published as is, non-GoDaddy consumers who download this package won't be able to install it unless they delete or ignore the package lock file.
There was a problem hiding this comment.
Ohh yea, good point. I think I might have missed this step in my previous PR as well 🤦
dbbfb5c to
1ba9eea
Compare
0d249f5 to
9fff670
Compare
9fff670 to
8173db2
Compare

Summary
Enhanced the slide transition so that
goToSlideworks for multiple slides at a time when looping left or right. Previously there was a bug withgoToSlidewhere when looping around left, the offset would be incorrect and cause the animation to look incorrect. This fixes that issue and enforces the use of thedirectionargument when looping the slider around left or right.Changelog
Enhanced the slide transition so that
goToSliderespects thedirectionprop and works for transitioning multiple slides at a time wheninfiniteis set to true.Also enhanced jsdom to mock viewport width and height for tests.
Test Plan
Added unit tests for calcLeftOffset for various scenarios and conducted manual testing of infinite and non-infinite scrolling cases.
Before:
Video.Project.9.mp4
After:
Video.Project.9.mp4