Skip to content

Commit cceec03

Browse files
committed
Hide loading animation after media has been loaded
Showing the animation looks realy annoying behind smaller images or images with transparent parts.
1 parent beb97b2 commit cceec03

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/css/swipebox.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ html.swipebox-html.swipebox-touch {
3131
display: none;
3232
}
3333
#swipebox-slider .slide {
34-
background: url(../img/loader.gif) no-repeat center center;
3534
height: 100%;
3635
width: 100%;
3736
line-height: 1px;
3837
text-align: center;
3938
display: inline-block;
4039
}
40+
#swipebox-slider .slide-loading {
41+
background: url(./loader.gif) no-repeat center center;
42+
}
4143
#swipebox-slider .slide:before {
4244
content: "";
4345
display: inline-block;

src/js/jquery.swipebox.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,16 @@
597597
return false;
598598
}
599599

600+
var slide = $( '#swipebox-slider .slide' ).eq( index );
601+
600602
if ( ! $this.isVideo( src ) ) {
603+
slide.addClass( 'slide-loading' );
601604
$this.loadMedia( src, function() {
602-
$( '#swipebox-slider .slide' ).eq( index ).html( this );
605+
slide.removeClass( 'slide-loading' );
606+
slide.html( this );
603607
} );
604608
} else {
605-
$( '#swipebox-slider .slide' ).eq( index ).html( $this.getVideo( src ) );
609+
slide.html( $this.getVideo( src ) );
606610
}
607611

608612
},

0 commit comments

Comments
 (0)