Skip to content

Commit 91d8912

Browse files
author
Constantin Saguin
committed
Merge pull request brutaldesign#147 from stackcoder/pull-request-loading-animation
Hide loading animation after media has been loaded
2 parents e3339c1 + fde9dee commit 91d8912

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

scss/swipebox.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ html.swipebox-html.swipebox-touch {
4545
display: none;
4646

4747
.slide {
48-
background: url(../img/loader.gif) no-repeat center center;
4948
height: 100%;
5049
width: 100%;
5150
line-height: 1px;
@@ -96,6 +95,10 @@ html.swipebox-html.swipebox-touch {
9695
}
9796
}
9897
}
98+
99+
.slide-loading {
100+
background: url(../img/loader.gif) no-repeat center center;
101+
}
99102

100103
}
101104

@@ -240,4 +243,4 @@ html.swipebox-html.swipebox-touch {
240243
font-size: 15px;
241244
line-height: 43px;
242245
font-family: Helvetica, Arial, sans-serif;
243-
}
246+
}

src/css/swipebox.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ html.swipebox-html.swipebox-touch {
3535
-webkit-backface-visibility: hidden;
3636
}
3737
#swipebox-slider .slide {
38-
background: url(../img/loader.gif) no-repeat center center;
3938
height: 100%;
4039
width: 100%;
4140
line-height: 1px;
4241
text-align: center;
4342
display: inline-block;
4443
}
44+
#swipebox-slider .slide-loading {
45+
background: url(./loader.gif) no-repeat center center;
46+
}
4547
#swipebox-slider .slide:before {
4648
content: "";
4749
display: inline-block;

src/js/jquery.swipebox.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,16 @@
680680
return false;
681681
}
682682

683+
var slide = $( '#swipebox-slider .slide' ).eq( index );
684+
683685
if ( ! $this.isVideo( src ) ) {
686+
slide.addClass( 'slide-loading' );
684687
$this.loadMedia( src, function() {
685-
$( '#swipebox-slider .slide' ).eq( index ).html( this );
688+
slide.removeClass( 'slide-loading' );
689+
slide.html( this );
686690
} );
687691
} else {
688-
$( '#swipebox-slider .slide' ).eq( index ).html( $this.getVideo( src ) );
692+
slide.html( $this.getVideo( src ) );
689693
}
690694

691695
},

0 commit comments

Comments
 (0)