Skip to content

Instantly share code, notes, and snippets.

@sokoljr
Created February 6, 2017 09:18
Show Gist options
  • Save sokoljr/ffed8559ca986bbff9fc97f80d16e8d6 to your computer and use it in GitHub Desktop.
Save sokoljr/ffed8559ca986bbff9fc97f80d16e8d6 to your computer and use it in GitHub Desktop.
Slider full bg image
/*BG slider*/
var bgImgSlide = [
'images/gm_slot_bg.jpg',
'images/gms_deluxe_bg.jpg',
'images/million_bg.jpg',
'images/vulkan_bg.jpg'
], i=1;
function slideBg(){
if(i > (bgImgSlide.length-1)){
$('.slide_bg').animate({'opacity':'0'},400,function(){
i=1;
$('.slide_bg').css({'background':'url('+bgImgSlide[0]+')','background-size':'cover', 'background-position':'center'});
});
$('.slide_bg').animate({'opacity':'1'},400);
}else{
$('.slide_bg').animate({'opacity':'0'},400,function(){
$('.slide_bg').css({'background':'url('+bgImgSlide[i]+')', 'background-size':'cover', 'background-position':'center'});
i++;
});
$('.slide_bg').animate({'opacity':'1'},400);
}
}
var intervalslideBg = setInterval(slideBg,6000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment