Repository navigation
[Feature] - Vertical Scrolling Update - #176
Conversation
🦋 Changeset detectedLatest commit: e624c52 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| // Divide the container width, by the marquee width and round it up | ||
| // to give us the ammount of items needed to fill the container. | ||
| let neededAmount = Math.ceil(containerWidth / marqueeWidth) * 2 - 1 | ||
| let neededAmount = Math.ceil(containerSize / marqueeSize) * 2 - 1 |
There was a problem hiding this comment.
I think that a vertical setup can cause neededAmount to grow without limit if the implementing user doesn't set up a fixed height on the parent element and there is no further limiting element. Let's maybe update this to provide a flexible maximum for neededAmount.
| let neededAmount = Math.ceil(containerSize / marqueeSize) * 2 - 1 | |
| const viewportSize = vertical ? window.innerHeight : window.innerWidth | |
| let neededAmount = Math.min( | |
| Math.ceil(containerSize / marqueeSize), | |
| Math.ceil(viewportSize / marqueeSize)) * 2 - 1 |
There was a problem hiding this comment.
Good suggestion, I've added this to prevent a ton of extra slides from being generated in that circumstance.
| setDuration(marqueeWidth / speedAmount) | ||
| setDuration(marqueeSize / speedAmount) | ||
| } | ||
| }, [prefersReducedMotion, reducedMotionSpeed, speed]) |
There was a problem hiding this comment.
That lint error is also the cause of a strange side effect error. Let's ypdate these deps to include vertical and move getRelevantDimensions into the callback.
Description
Connected task (Flamingo): https://wethecollective.teamwork.com/app/tasks/27444955
This adds an optional prop to the marquee that enables it to animate vertically. Existing parameters still work as you'd expect (
reverse,reduceMotionSpeed, etc).Solution
I tried to keep the marquee as similar to the existing state as possible. There were multiple references to width that I renamed to size, to be more generic, but nothing that should have impact on the default behaviour. No new markup was introduced, and the CSS for vertical movement is separate from the standard CSS.
Note: I updated several variable names to remove references to width, but left the CSS variable
--marquee-width, as there's an (albeit very unlikely) chance this may have been in acalcor something on some implementation of this component.The downside to a vertical marquee is that the height of elements is a troublesome thing to calculate, compared to width. I ended up settling for requiring the parent of the marquee to have an explicit
height,display: flex, andoverflow: clip(which is highly suggested). All requirements are noted in the docs.Additional Notes
Tested standard (horizontal) marquee usage and encountered no issues. Also tested in all major browsers and in the iOS simulator without issue.
Screenshots
Mockup of standard usage (including reverse):
Screen.Recording.2026-11-25.at.12.43.13.PM.mov
Mockup of how this would look similar to the Flamingo setup (setting only
widthinline on the image elements (and the same image dimensions), and addingmax-width: 100%to the images, slides, and marquee, andwidth: 50%to the containers.Screen.Recording.2026-11-25.at.12.52.46.PM.mov