easeIn.js.flow 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // @flow
  2. import type { TimingFunction } from '../types/timingFunction'
  3. const functionsMap = {
  4. back: 'cubic-bezier(0.600, -0.280, 0.735, 0.045)',
  5. circ: 'cubic-bezier(0.600, 0.040, 0.980, 0.335)',
  6. cubic: 'cubic-bezier(0.550, 0.055, 0.675, 0.190)',
  7. expo: 'cubic-bezier(0.950, 0.050, 0.795, 0.035)',
  8. quad: 'cubic-bezier(0.550, 0.085, 0.680, 0.530)',
  9. quart: 'cubic-bezier(0.895, 0.030, 0.685, 0.220)',
  10. quint: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)',
  11. sine: 'cubic-bezier(0.470, 0.000, 0.745, 0.715)',
  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': easeIn('quad')
  20. * }
  21. *
  22. * // styled-components usage
  23. * const div = styled.div`
  24. * transitionTimingFunction: ${easeIn('quad')};
  25. * `
  26. *
  27. * // CSS as JS Output
  28. *
  29. * 'div': {
  30. * 'transitionTimingFunction': 'cubic-bezier(0.550, 0.085, 0.680, 0.530)',
  31. * }
  32. */
  33. export default function easeIn(functionName: string): TimingFunction {
  34. return functionsMap[functionName.toLowerCase().trim()]
  35. }