mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 20:19:44 +08:00
1c8f6507ce
* site: imp * update fontsize * add scrollTo(0) * revert * add style return type * add resize Event when input onChange * docs: fix affix height and revert resize event * fix: justifycontent => justify-content * fix style Co-authored-by: afc163 <afc163@gmail.com>
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
|
|
import CSSMotion from 'rc-motion';
|
|
import React from 'react';
|
|
|
|
export interface LoadingIconProps {
|
|
prefixCls: string;
|
|
existIcon: boolean;
|
|
loading?: boolean | object;
|
|
}
|
|
|
|
const getCollapsedWidth = (): React.CSSProperties => ({
|
|
width: 0,
|
|
opacity: 0,
|
|
transform: 'scale(0)',
|
|
});
|
|
|
|
const getRealWidth = (node: HTMLElement): React.CSSProperties => ({
|
|
width: node.scrollWidth,
|
|
opacity: 1,
|
|
transform: 'scale(1)',
|
|
});
|
|
|
|
const LoadingIcon: React.FC<LoadingIconProps> = ({ prefixCls, loading, existIcon }) => {
|
|
const visible = !!loading;
|
|
|
|
if (existIcon) {
|
|
return (
|
|
<span className={`${prefixCls}-loading-icon`}>
|
|
<LoadingOutlined />
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<CSSMotion
|
|
visible={visible}
|
|
// We do not really use this motionName
|
|
motionName={`${prefixCls}-loading-icon-motion`}
|
|
removeOnLeave
|
|
onAppearStart={getCollapsedWidth}
|
|
onAppearActive={getRealWidth}
|
|
onEnterStart={getCollapsedWidth}
|
|
onEnterActive={getRealWidth}
|
|
onLeaveStart={getRealWidth}
|
|
onLeaveActive={getCollapsedWidth}
|
|
>
|
|
{({ className, style }: { className?: string; style?: React.CSSProperties }, ref: any) => (
|
|
<span className={`${prefixCls}-loading-icon`} style={style} ref={ref}>
|
|
<LoadingOutlined className={className} />
|
|
</span>
|
|
)}
|
|
</CSSMotion>
|
|
);
|
|
};
|
|
|
|
export default LoadingIcon;
|