FormidableLabs / nuka-carousel

Small, fast, and accessibility-first React carousel library with an easily customizable UI and behavior to fit your brand and site.
https://commerce.nearform.com/open-source/nuka-carousel
Other
3k stars 596 forks source link

Alternative easing api and `edgeEasing` prop #971

Closed fritz-c closed 1 year ago

fritz-c commented 1 year ago

Description

Instead of bundling in the d3-ease functions, the easing prop now accepts a callback that accepts functions of a form identical to d3-ease’s ease functions. That way those who want to customize their easing function can, those who want to use d3-ease’s functions can (and benefit from tree-shaking of the ones they don't use), and those who are happy with the default don't have to bear the extra weight of added d3 ease functions. And we get to sidestep all the d3 ESM mess. The README now includes a code snippet showing how users might use the new API.

As I was working on that, I noticed there was an old easing prop, edgeEasing that hadn't been addressed yet, so I added that in, too.

And as I was working on that, I noticed that there's a bit of an animation bug in that edge swipes result in the carousel flashing into its final position for one frame before starting the animation, so I added a kind of rough workaround for that.

Type of Change

How Has This Been Tested?

Manually

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nuka-carousel ✅ Ready (Inspect) Visit Preview Sep 14, 2022 at 5:08PM (UTC)
gksander commented 1 year ago

I really like this approach. I think it's great to not burden all users with d3 bloat – and just allow users who do want to use d3 eases to provide it on their own.