[Feat]: Add offset option for fine-tuned slide alignment#1302
[Feat]: Add offset option for fine-tuned slide alignment#1302marcusmichaels wants to merge 2 commits intodavidjerleke:masterfrom
Conversation
Add a new `offset` option (default: 0) that shifts all snap positions by a fixed pixel amount. Positive values shift slides in the start direction, negative values shift in the end direction. All exsting functionality (alignment, containScroll, loop, drag, progress, SSR) remains unchanged. Includes tests for LTR, RTL, and vertical axes. This addition allows us to fine-tune the placement without impacting the core functionality
|
@davidjerleke I've added this PR following on from #1301 – let me know what you think, it's a really helpful addition for our pixel-perfect design-focused team so I think it'll be a positive addition to the project. |
|
Just wanted to add, since this can already be achieved with a custom The reason I feel a dedicated The intent is immediately clear to anyone reading the config. But it's your shout anyway. |
@marcusmichaels Thanks a lot for your contribution! Do you see any advantages to what can be achieved with this offset option compared to the current align function? Can both accomplish the same outcomes, or is one approach more flexible/limiting than the other? |
|
Hey @davidjerleke, thanks for looking at this. From my personal experience, one of the main benefits would have been discoverability around alignment options. I didn't initially realise the align options also took a function until I traced through the types. For more real-world context, I ended up building a helper function using the current alignment options called This does a couple of things, it does the maths to calculate where "start" would be, and then nudges it over I kind of feel like |
This PR follows on from #1301 and adds a new
offsetoption (default: 0) that shifts all snap positions by a fixed pixel amount. Positive values shift slides in the start direction, negative values shift in the end direction.All exsting functionality (alignment, containScroll, loop, drag, progress, SSR) remains unchanged. Includes tests for LTR, RTL, and vertical axes.
This addition allows us to fine-tune the placement without impacting the core functionality.
P.S. The majority of lines added are tests, the bore changes are relatively lightweight