click光晕效果
ant-click-animating-withou
image.png
Wave 实现了这个光晕效果
Wave 组件会在点击的时候给 Button 组件加上 ant-click-animating-without-extra-node,
css 代码给有这个属性的元素加上了这个光晕效果

  1. <Wave>
  2. <button
  3. {...otherProps}
  4. type={htmlType || 'button'}
  5. className={classes}
  6. onClick={this.handleClick}
  7. title={title}
  8. >
  9. {iconNode}{kids}
  10. </button>
  11. </Wave>

css代码

  1. [ant-click-animating],
  2. [ant-click-animating-without-extra-node] {
  3. position: relative;
  4. }
  5. [ant-click-animating-without-extra-node]:after,
  6. .ant-click-animating-node {
  7. content: '';
  8. position: absolute;
  9. top: -1px;
  10. left: -1px;
  11. bottom: -1px;
  12. right: -1px;
  13. border-radius: inherit;
  14. border: 0 solid #1890ff;
  15. opacity: 0.2;
  16. -webkit-animation: fadeEffect 2s cubic-bezier(0.08, 0.82, 0.17, 1), waveEffect 0.4s cubic-bezier(0.08, 0.82, 0.17, 1);
  17. animation: fadeEffect 2s cubic-bezier(0.08, 0.82, 0.17, 1), waveEffect 0.4s cubic-bezier(0.08, 0.82, 0.17, 1);
  18. -webkit-animation-fill-mode: forwards;
  19. animation-fill-mode: forwards;
  20. display: block;
  21. pointer-events: none;
  22. }
  23. @-webkit-keyframes waveEffect {
  24. 100% {
  25. top: -6px;
  26. left: -6px;
  27. bottom: -6px;
  28. right: -6px;
  29. border-width: 6px;
  30. }
  31. }
  32. @keyframes waveEffect {
  33. 100% {
  34. top: -6px;
  35. left: -6px;
  36. bottom: -6px;
  37. right: -6px;
  38. border-width: 6px;
  39. }
  40. }
  41. @-webkit-keyframes fadeEffect {
  42. 100% {
  43. opacity: 0;
  44. }
  45. }
  46. @keyframes fadeEffect {
  47. 100% {
  48. opacity: 0;
  49. }
  50. }

删除光晕效果

在不修改 antd 源码的情况下,ant-click-animating-without-extra-node 这个属性是去不掉的,
只有通过 css 去掉这个效果

  1. button[ant-click-animating-without-extra-node]:after {
  2. border: 0 none;
  3. opacity: 0;
  4. animation:none 0 ease 0 1 normal;
  5. }

https://juejin.cn/post/7064404257436336135