placement.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { Keyframes } from '@ant-design/cssinjs';
  2. const genNotificationPlacementStyle = token => {
  3. const {
  4. componentCls,
  5. notificationMarginEdge,
  6. animationMaxHeight
  7. } = token;
  8. const noticeCls = `${componentCls}-notice`;
  9. const rightFadeIn = new Keyframes('antNotificationFadeIn', {
  10. '0%': {
  11. transform: `translate3d(100%, 0, 0)`,
  12. opacity: 0
  13. },
  14. '100%': {
  15. transform: `translate3d(0, 0, 0)`,
  16. opacity: 1
  17. }
  18. });
  19. const topFadeIn = new Keyframes('antNotificationTopFadeIn', {
  20. '0%': {
  21. top: -animationMaxHeight,
  22. opacity: 0
  23. },
  24. '100%': {
  25. top: 0,
  26. opacity: 1
  27. }
  28. });
  29. const bottomFadeIn = new Keyframes('antNotificationBottomFadeIn', {
  30. '0%': {
  31. bottom: token.calc(animationMaxHeight).mul(-1).equal(),
  32. opacity: 0
  33. },
  34. '100%': {
  35. bottom: 0,
  36. opacity: 1
  37. }
  38. });
  39. const leftFadeIn = new Keyframes('antNotificationLeftFadeIn', {
  40. '0%': {
  41. transform: `translate3d(-100%, 0, 0)`,
  42. opacity: 0
  43. },
  44. '100%': {
  45. transform: `translate3d(0, 0, 0)`,
  46. opacity: 1
  47. }
  48. });
  49. return {
  50. [componentCls]: {
  51. [`&${componentCls}-top, &${componentCls}-bottom`]: {
  52. marginInline: 0,
  53. [noticeCls]: {
  54. marginInline: 'auto auto'
  55. }
  56. },
  57. [`&${componentCls}-top`]: {
  58. [`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]: {
  59. animationName: topFadeIn
  60. }
  61. },
  62. [`&${componentCls}-bottom`]: {
  63. [`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]: {
  64. animationName: bottomFadeIn
  65. }
  66. },
  67. [`&${componentCls}-topRight, &${componentCls}-bottomRight`]: {
  68. [`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]: {
  69. animationName: rightFadeIn
  70. }
  71. },
  72. [`&${componentCls}-topLeft, &${componentCls}-bottomLeft`]: {
  73. marginRight: {
  74. value: 0,
  75. _skip_check_: true
  76. },
  77. marginLeft: {
  78. value: notificationMarginEdge,
  79. _skip_check_: true
  80. },
  81. [noticeCls]: {
  82. marginInlineEnd: 'auto',
  83. marginInlineStart: 0
  84. },
  85. [`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]: {
  86. animationName: leftFadeIn
  87. }
  88. }
  89. }
  90. };
  91. };
  92. export default genNotificationPlacementStyle;