chenglou / react-motion

A spring that solves your animation problems.
MIT License
21.71k stars 1.15k forks source link

expose spring defaultConfig to user to customize #481

Closed hardfist closed 7 years ago

hardfist commented 7 years ago

It seems that spring function has a defaultConfig, But It isn't exposed to user. but the animation according to defaultConfig seems a little slow, so I have to pass my customized spring presets to spring everywhere , so I wonder if you could expose defaultConfig to user to Customize. thanks!

nkbt commented 7 years ago

I don't think it is possible, since you would need to carry React Motion instance around your app or smth. If we allow to mutate defaultConfig, it means all instances will get that. It is quite a bad design decision for a general-purpose library.

Instead, create your own spring with your own custom default config. Something like

const myDefaultPreset = {stiffness, damping};
export const mySpring = (value, presetOverride) => 
  spring(value, {...myDefaultPreset, ...presetOverride});