Skip to content

Commit 63093b6

Browse files
李钿李钿
authored andcommitted
增加默认Loading组件
1 parent 6449c58 commit 63093b6

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/components/ImageContainer.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33

44
import raf from 'raf';
55
import tween from './tween.js'
6+
import Loading from './Loading'
67

78
/**
89
*
@@ -467,7 +468,7 @@ class ImageContainer extends PureComponent {
467468
onTouchEnd={this.handleTouchEnd}
468469
style={defaultStyle}>
469470
{
470-
isLoaded ? <img src={src} style={ImageStyle}/> : ''
471+
isLoaded ? <img src={src} style={ImageStyle}/> : <Loading/>
471472
}
472473
</div>
473474
);

src/components/Loading.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
3+
const Loading = (props) => {
4+
return (
5+
<div className="viewer-image-loading">
6+
</div>
7+
);
8+
};
9+
10+
export default Loading;

src/components/WxImageViewer.less

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,29 @@
5555
}
5656
}
5757
}
58+
.viewer-image-loading{
59+
position: absolute;
60+
margin: auto;
61+
left: 0;
62+
right: 0;
63+
top: 0;
64+
bottom: 0;
65+
width: 32px;
66+
height: 32px;
67+
box-sizing: border-box;
68+
border-radius: 100%;
69+
border-width: 4px;
70+
border-style: solid;
71+
border-color: #333;
72+
border-bottom-color: #FFF;
73+
animation: roll 1s linear infinite;
74+
}
75+
@keyframes roll{
76+
from{
77+
transform: rotate(0deg);
78+
}
79+
to{
80+
transform: rotate(360deg);
81+
}
82+
}
5883
}

0 commit comments

Comments
 (0)