Skip to content
This repository was archived by the owner on Jan 19, 2023. It is now read-only.

Commit 7911314

Browse files
committed
Create loading icon
1 parent 0da0996 commit 7911314

File tree

2 files changed

+99
-3
lines changed

2 files changed

+99
-3
lines changed

src/react-image-lightbox.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import baseStyles from './style.scss';
2626

2727
// Add fallback classes for browsers without flexbox support
2828
let styles = baseStyles;
29-
if (getIEVersion() < 10) {
29+
const _ieVersion = getIEVersion();
30+
if (_ieVersion < 10) {
3031
styles = {
3132
...styles,
3233
toolbarSide: `${styles.toolbarSide} ${styles.toolbarSideNoFlex}`,
@@ -799,13 +800,43 @@ class ReactImageLightbox extends Component {
799800

800801
const bestImageInfo = this.getBestImageForType(srcType);
801802
if (bestImageInfo === null) {
803+
let loadingIcon;
804+
if (_ieVersion < 10) {
805+
loadingIcon = (
806+
<div className={styles.loadingContainer__icon} >
807+
Loading...
808+
</div>
809+
);
810+
} else {
811+
loadingIcon = (
812+
<div className={`${styles.loadingCircle} ${styles.loadingContainer__icon}`}>
813+
<div className={styles.loadingCirclePoint}></div>
814+
<div className={styles.loadingCirclePoint}></div>
815+
<div className={styles.loadingCirclePoint}></div>
816+
<div className={styles.loadingCirclePoint}></div>
817+
<div className={styles.loadingCirclePoint}></div>
818+
<div className={styles.loadingCirclePoint}></div>
819+
<div className={styles.loadingCirclePoint}></div>
820+
<div className={styles.loadingCirclePoint}></div>
821+
<div className={styles.loadingCirclePoint}></div>
822+
<div className={styles.loadingCirclePoint}></div>
823+
<div className={styles.loadingCirclePoint}></div>
824+
<div className={styles.loadingCirclePoint}></div>
825+
</div>
826+
);
827+
}
828+
802829
// Fall back to loading icon if the thumbnail has not been loaded
803830
images.push(
804831
<div
805832
className={`${imageClass} ${styles.image} not-loaded`}
806833
style={imageStyle}
807834
key={this.props[srcType] + keyEndings[srcType]}
808-
/>
835+
>
836+
<div className={styles.loadingContainer} >
837+
{loadingIcon}
838+
</div>
839+
</div>
809840
);
810841

811842
return;

src/style.scss

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ $toolbarHeight: 50px;
147147
display: inline-block;
148148
line-height: $toolbarHeight;
149149
padding: 0;
150-
color: #FFFFFF;
150+
color: #FFF;
151151
font-size: 120%;
152152
max-width: 100%;
153153
overflow: hidden;
@@ -199,3 +199,68 @@ $toolbarHeight: 50px;
199199
.outerAnimating {
200200
animation-name: closeWindow;
201201
}
202+
203+
@keyframes pointFade {
204+
0%, 19.999%, 100% { opacity: 0; }
205+
20% { opacity: 1; }
206+
}
207+
208+
.loadingCircle {
209+
width: 60px;
210+
height: 60px;
211+
position: relative;
212+
}
213+
214+
.loadingCirclePoint {
215+
width: 100%;
216+
height: 100%;
217+
position: absolute;
218+
left: 0;
219+
top: 0;
220+
221+
$point-count: 12;
222+
$spin-animation-time: 1200ms;
223+
224+
&:before {
225+
content: '';
226+
display: block;
227+
margin: 0 auto;
228+
width: 15%;
229+
height: 15%;
230+
background-color: #FFF;
231+
border-radius: 30%;
232+
animation: pointFade $spin-animation-time infinite ease-in-out both;
233+
}
234+
235+
@for $i from 1 through (($point-count + 1) / 2) {
236+
&:nth-of-type(#{$i}) {
237+
transform: rotate(360deg / $point-count * ($i - 1));
238+
}
239+
240+
&:nth-of-type(#{$i + $point-count / 2}) {
241+
transform: rotate(180deg + 360deg / $point-count * ($i - 1));
242+
}
243+
244+
&:nth-of-type(#{$i}), &:nth-of-type(#{$i + $point-count / 2}) {
245+
&:before {
246+
animation-delay: - $spin-animation-time + ($spin-animation-time / $point-count * 2 * ($i - 1));
247+
}
248+
}
249+
}
250+
}
251+
252+
.loadingContainer {
253+
position: absolute;
254+
top: 0;
255+
right: 0;
256+
bottom: 0;
257+
left: 0;
258+
}
259+
260+
.loadingContainer__icon {
261+
color: #FFF;
262+
position: absolute;
263+
top: 50%;
264+
left: 50%;
265+
transform: translateX(-50%) translateY(-50%);
266+
}

0 commit comments

Comments
 (0)