标签
note
字数
183 字
阅读时间
1 分钟

特点:
Wave本身是一个组件,将需要实现点击特效的元素通过props.children传入。无侵入,使用伪元素执行特效,不会破坏原有的 Dom 层次结构。- 扩散特效颜色跟随被点击元素边框
自动改变。
css 效果通过 animation + boxShadow 实现
css
[ant-click-animating-without-extra-node='true'] {
position: relative;
}
[ant-click-animating-without-extra-node='true']::after {
position: absolute;
top: -1px;
right: -1px;
bottom: -1px;
left: -1px;
display: block;
border: 0 solid @primary-color;
border-radius: inherit;
opacity: 0.2;
animation: fadeEffect 2s @ease-out-circ, waveEffect 0.4s @ease-out-circ;
animation-fill-mode: forwards;
pointer-events: none;
content: '';
}
@keyframes waveEffect {
100% {
top: -@wave-animation-width;
right: -@wave-animation-width;
bottom: -@wave-animation-width;
left: -@wave-animation-width;
border-width: @wave-animation-width;
}
}
@keyframes fadeEffect {
100% {
opacity: 0;
}
}参考
「antd 源码分析」Wave——元素点击扩散效果 - Eastblue