Skip to content

Commit a5a9ff8

Browse files
author
Constantin Saguin
committed
2 parents beb97b2 + 16b1529 commit a5a9ff8

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ hideBarsOnMobile : true, // false will show the caption and navbar on mobile dev
6565
hideBarsDelay : 3000, // 0 to always show caption and action bar
6666
videoMaxWidth : 1140, // videos max width
6767
beforeOpen: function(){} , // called before opening
68-
afterClose: function(){} // called after closing
68+
afterClose: function(){}, // called after closing
69+
loopAtEnd: false // true will return to the first image after the last image is reached
6970
```
7071

7172
###Pull Requests

src/js/jquery.swipebox.js

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
vimeoColor : 'CCCCCC',
1818
beforeOpen: null,
1919
afterOpen: null,
20-
afterClose: null
20+
afterClose: null,
21+
loopAtEnd: false
2122
},
2223

2324
plugin = this,
@@ -42,6 +43,14 @@
4243
</div>';
4344

4445
plugin.settings = {};
46+
47+
$.swipebox.close = function (){
48+
ui.closeSlide();
49+
};
50+
51+
$.swipebox.extend = function (){
52+
return ui;
53+
}
4554

4655
plugin.init = function() {
4756

@@ -455,8 +464,10 @@
455464
$this.clearTimeout();
456465

457466
}, function() {
467+
if (plugin.settings.hideBarsDelay > 0){
458468
bars.removeClass( 'visible-bars' );
459469
$this.setTimeout();
470+
}
460471

461472
} );
462473

@@ -545,7 +556,7 @@
545556

546557
if ( index === 0 ) {
547558
$( '#swipebox-prev' ).addClass( 'disabled' );
548-
} else if ( index === elements.length - 1 ) {
559+
} else if ( index === elements.length - 1 && plugin.settings.loopAtEnd != true) {
549560
$( '#swipebox-next' ).addClass( 'disabled' );
550561
}
551562
},
@@ -633,6 +644,11 @@
633644
if ( src.match( /youtube\.com\/watch\?v=([a-zA-Z0-9\-_]+)/) || src.match( /vimeo\.com\/([0-9]*)/ ) || src.match( /youtu\.be\/([a-zA-Z0-9\-_]+)/ ) ) {
634645
return true;
635646
}
647+
648+
if (src.toLowerCase().indexOf( "swipeboxvideo=1" ) >= 0){
649+
650+
return true;
651+
}
636652
}
637653

638654
},
@@ -656,6 +672,12 @@
656672
iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?byline=0&amp;portrait=0&amp;color='+plugin.settings.vimeoColor+'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
657673

658674
}
675+
676+
if (youtubeShortUrl || youtubeShortUrl || vimeoUrl){
677+
678+
} else {
679+
iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>';
680+
}
659681

660682
return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videomaxWidth + 'px"><div class="swipebox-video">'+iframe+'</div></div>';
661683
},
@@ -680,16 +702,26 @@
680702
var $this = this,
681703
index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
682704
if ( index+1 < elements.length ) {
705+
var src = $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src");
706+
$( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src",src);
683707
index++;
684708
$this.setSlide( index );
685709
$this.preloadMedia( index+1 );
686-
687710
} else {
688711

689-
$( '#swipebox-slider' ).addClass( 'rightSpring' );
690-
setTimeout( function() {
691-
$( '#swipebox-slider' ).removeClass( 'rightSpring' );
692-
}, 500 );
712+
if (plugin.settings.loopAtEnd === true){
713+
var src = $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src");
714+
$( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src",src);
715+
index = 0;
716+
$this.preloadMedia( index );
717+
$this.setSlide( index );
718+
$this.preloadMedia( index + 1 );
719+
} else {
720+
$( '#swipebox-slider' ).addClass( 'rightSpring' );
721+
setTimeout( function() {
722+
$( '#swipebox-slider' ).removeClass( 'rightSpring' );
723+
}, 500 );
724+
}
693725
}
694726
},
695727

@@ -699,16 +731,17 @@
699731
getPrev : function () {
700732
var index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) );
701733
if ( index > 0 ) {
734+
var src = $( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src");
735+
$( '#swipebox-slider .slide' ).eq(index).contents().find("iframe").attr("src",src);
702736
index--;
703737
this.setSlide( index );
704738
this.preloadMedia( index-1 );
705739
} else {
706-
707-
$( '#swipebox-slider' ).addClass( 'leftSpring' );
708-
setTimeout( function() {
709-
$( '#swipebox-slider' ).removeClass( 'leftSpring' );
710-
}, 500 );
711-
}
740+
$( '#swipebox-slider' ).addClass( 'leftSpring' );
741+
setTimeout( function() {
742+
$( '#swipebox-slider' ).removeClass( 'leftSpring' );
743+
}, 500 );
744+
}
712745
},
713746

714747
/**

0 commit comments

Comments
 (0)