Skip to content

Commit 4f85519

Browse files
feat: 更换spin动画 (#2925)
* feat: 更换spin动画 * fix: modify the loading animation style of button --------- Co-authored-by: zhangyumei.0319 <zhangyumei.0319@bytedance.com>
1 parent 6ee0dec commit 4f85519

File tree

4 files changed

+68
-37
lines changed

4 files changed

+68
-37
lines changed

packages/semi-foundation/button/iconButton.scss

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@
44
$module: #{$prefix}-button;
55

66
.#{$module} {
7+
@keyframes #{$prefix}-animation-rotate {
8+
from {
9+
transform: rotate(0);
10+
}
11+
to {
12+
transform: rotate(360deg);
13+
}
14+
}
15+
16+
@keyframes #{$prefix}-animation-circle {
17+
0% {
18+
stroke-dasharray: 1, 220;
19+
stroke-dashoffset: 0;
20+
}
21+
50% {
22+
stroke-dasharray: 150, 220;
23+
stroke-dashoffset: -68px;
24+
}
25+
100% {
26+
stroke-dasharray: 150, 220;
27+
stroke-dashoffset: -218px;
28+
}
29+
}
30+
731
&.#{$module}-with-icon {
832
display: inline-flex;
933
align-items: center;
@@ -24,8 +48,12 @@ $module: #{$prefix}-button;
2448
&>svg {
2549
width: 16px;
2650
height: 16px;
27-
animation: .6s linear infinite #{$prefix}-animation-rotate;
51+
animation: 1200ms linear infinite #{$prefix}-animation-rotate;
2852
animation-fill-mode: forwards;
53+
54+
& > circle {
55+
animation: 2500ms ease-in-out infinite #{$prefix}-animation-circle;
56+
}
2957
}
3058
}
3159
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
$animation_duration-spin_wrapper-spin: 600ms; // 加载图标容器旋转一周时长
2-
$animation_duration-spin_customChildren-spin: 1600ms; // 自定义指示器时旋转一周时长
1+
$animation_duration-spin_wrapper-spin: 1200ms; // 加载图标容器旋转一周时长
2+
$animation_duration-spin_customChildren-spin: 1600ms; // 自定义指示器时旋转一周时长
3+
$animation_duration-spin_wrapper-spin-circle: 2500ms; // 加载图标弹性运动一周时长

packages/semi-foundation/spin/spin.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ $module: #{$prefix}-spin;
1818
}
1919
}
2020

21+
@keyframes #{$prefix}-animation-circle {
22+
0% {
23+
stroke-dasharray: 1, 220;
24+
stroke-dashoffset: 0;
25+
}
26+
50% {
27+
stroke-dasharray: 150, 220;
28+
stroke-dashoffset: -68px;
29+
}
30+
100% {
31+
stroke-dasharray: 150, 220;
32+
stroke-dashoffset: -218px;
33+
}
34+
}
35+
2136
&-wrapper {
2237
text-align: center;
2338
position: absolute;
@@ -27,10 +42,15 @@ $module: #{$prefix}-spin;
2742
color: $color-spin-bg;
2843

2944
& > svg {
45+
display: inline;
3046
animation: $animation_duration-spin_wrapper-spin linear infinite #{$prefix}-animation-rotate;
3147
animation-fill-mode: forwards;
3248
vertical-align: top;
3349
@include size($width-spin_middle);
50+
51+
& > circle {
52+
animation: $animation_duration-spin_wrapper-spin-circle ease-in-out infinite #{$prefix}-animation-circle;
53+
}
3454
}
3555
}
3656

packages/semi-ui/spin/icon.tsx

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/* eslint-disable no-unused-vars */
22
import React from 'react';
3-
import isNullOrUndefined from '@douyinfe/semi-foundation/utils/isNullOrUndefined';
4-
5-
let _id = -1;
63

74
export interface IconProps {
85
id?: number;
@@ -13,43 +10,28 @@ export interface IconProps {
1310
}
1411

1512
function Icon(props: IconProps = {}) {
16-
const { id: propsId, className, ...rest } = props;
17-
let _propsId = propsId;
18-
if (isNullOrUndefined(_propsId)) {
19-
_id++;
20-
_propsId = _id;
21-
}
22-
const id = `linearGradient-${_propsId}`;
13+
const { id, className, ...rest } = props;
2314
return (
2415
<svg
2516
{...rest}
2617
className={className}
27-
width="48"
28-
height="48"
29-
viewBox="0 0 36 36"
30-
version="1.1"
31-
xmlns="http://www.w3.org/2000/svg"
32-
aria-hidden
33-
data-icon="spin"
18+
width="100%"
19+
height="100%"
20+
viewBox="0 0 100 100"
3421
>
35-
<defs>
36-
<linearGradient x1="0%" y1="100%" x2="100%" y2="100%" id={id}>
37-
<stop stopColor="currentColor" stopOpacity="0" offset="0%" />
38-
<stop stopColor="currentColor" stopOpacity="0.50" offset="39.9430698%" />
39-
<stop stopColor="currentColor" offset="100%" />
40-
</linearGradient>
41-
</defs>
42-
<g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
43-
<rect fillOpacity="0.01" fill="none" x="0" y="0" width="36" height="36" />
44-
<path
45-
d="M34,18 C34,9.163444 26.836556,2 18,2 C11.6597233,2 6.18078805,5.68784135 3.59122325,11.0354951"
46-
stroke={`url(#${id})`}
47-
strokeWidth="4"
48-
strokeLinecap="round"
49-
/>
50-
</g>
22+
<circle
23+
cx="50"
24+
cy="50"
25+
r="35"
26+
stroke="currentColor"
27+
strokeWidth="11"
28+
strokeLinecap="round"
29+
strokeMiterlimit="10"
30+
fill="none"
31+
>
32+
</circle>
5133
</svg>
5234
);
5335
}
5436

55-
export default Icon;
37+
export default Icon;

0 commit comments

Comments
 (0)