easeOut.js.flow 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // @flow
  2. import type { TimingFunction } from '../types/timingFunction'
  3. const functionsMap = {
  4. back: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)',
  5. cubic: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)',
  6. circ: 'cubic-bezier(0.075, 0.820, 0.165, 1.000)',
  7. expo: 'cubic-bezier(0.190, 1.000, 0.220, 1.000)',
  8. quad: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
  9. quart: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)',
  10. quint: 'cubic-bezier(0.230, 1.000, 0.320, 1.000)',
  11. sine: 'cubic-bezier(0.390, 0.575, 0.565, 1.000)',
  12. }
  13. /**
  14. * String to represent common easing functions as demonstrated here: (github.com/jaukia/easie).
  15. *
  16. * @example
  17. * // Styles as object usage
  18. * const styles = {
  19. * 'transitionTimingFunction': easeOut('quad')
  20. * }
  21. *
  22. * // styled-components usage
  23. * const div = styled.div`
  24. * transitionTimingFunction: ${easeOut('quad')};
  25. * `
  26. *
  27. * // CSS as JS Output
  28. *
  29. * 'div': {
  30. * 'transitionTimingFunction': 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
  31. * }
  32. */
  33. export default function easeOut(functionName: string): TimingFunction {
  34. return functionsMap[functionName.toLowerCase().trim()]
  35. }