fade.js 950 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { Keyframes } from '../../_util/cssinjs';
  2. import { initMotion } from './motion';
  3. export const fadeIn = new Keyframes('antFadeIn', {
  4. '0%': {
  5. opacity: 0
  6. },
  7. '100%': {
  8. opacity: 1
  9. }
  10. });
  11. export const fadeOut = new Keyframes('antFadeOut', {
  12. '0%': {
  13. opacity: 1
  14. },
  15. '100%': {
  16. opacity: 0
  17. }
  18. });
  19. export const initFadeMotion = function (token) {
  20. let sameLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  21. const {
  22. antCls
  23. } = token;
  24. const motionCls = `${antCls}-fade`;
  25. const sameLevelPrefix = sameLevel ? '&' : '';
  26. return [initMotion(motionCls, fadeIn, fadeOut, token.motionDurationMid, sameLevel), {
  27. [`
  28. ${sameLevelPrefix}${motionCls}-enter,
  29. ${sameLevelPrefix}${motionCls}-appear
  30. `]: {
  31. opacity: 0,
  32. animationTimingFunction: 'linear'
  33. },
  34. [`${sameLevelPrefix}${motionCls}-leave`]: {
  35. animationTimingFunction: 'linear'
  36. }
  37. }];
  38. };