You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
3.1 KiB
86 lines
3.1 KiB
/*
|
|
* Created by: YaFedImYaEatIm.
|
|
* All creation credits belong to YaFedImApps.
|
|
*/
|
|
|
|
|
|
var ys_slider_no = 0;
|
|
var ys_slider_max_no = $(".ys-slide").length;
|
|
var timer;
|
|
var moving = false;
|
|
|
|
function gotoSlide(slide_no, force_left){
|
|
if (slide_no === "timer_increase"){//bad practice but :P IDC
|
|
slide_no = ys_slider_no + 1;
|
|
}
|
|
if (slide_no >= ys_slider_max_no){
|
|
slide_no = 0;
|
|
} else if (slide_no < 0){
|
|
slide_no = ys_slider_max_no - 1;
|
|
}
|
|
if (ys_slider_max_no > 1 && !moving && ys_slider_no !== slide_no){
|
|
moving = true;
|
|
$($(".ys-page-nav > span").get(slide_no)).addClass("ys-active");
|
|
$($(".ys-page-nav > span").get(ys_slider_no)).removeClass("ys-active");
|
|
//console.log("Slider incrementing!");
|
|
//hid one display the other TODO animate.
|
|
if ((slide_no > ys_slider_no || (ys_slider_no === ys_slider_max_no - 1 && slide_no === 0)) && force_left === false){
|
|
//show both
|
|
$($(".ys-slide").get(ys_slider_no)).css("display", "table");
|
|
$($(".ys-slide").get(slide_no)).css("display", "table");
|
|
|
|
var old_var = ys_slider_no;
|
|
|
|
$($(".ys-slide").get(ys_slider_no)).animate({left:"-=100%"},
|
|
{duration:1000, queue: false,
|
|
complete: function(){
|
|
$($(".ys-slide").get(old_var)).css("display", "none");
|
|
moving = false;
|
|
}});
|
|
|
|
$($(".ys-slide").get(slide_no)).css("left", "100%");
|
|
$($(".ys-slide").get(slide_no)).animate({left:"-=100%"},
|
|
{duration:1000, queue: false});
|
|
|
|
ys_slider_no = slide_no;
|
|
}else{
|
|
//show both
|
|
$($(".ys-slide").get(ys_slider_no)).css("display", "table");
|
|
$($(".ys-slide").get(slide_no)).css("display", "table");
|
|
|
|
var old_var = ys_slider_no;
|
|
|
|
$($(".ys-slide").get(ys_slider_no)).animate({left:"+=100%"},
|
|
{duration:1000, queue: false,
|
|
complete: function(){
|
|
$($(".ys-slide").get(old_var)).css("display", "none");
|
|
moving = false;
|
|
}});
|
|
|
|
$($(".ys-slide").get(slide_no)).css("left", "-100%");
|
|
$($(".ys-slide").get(slide_no)).animate({left:"+=100%"},
|
|
{duration:1000, queue: false});
|
|
|
|
ys_slider_no = slide_no;
|
|
}
|
|
}
|
|
}
|
|
|
|
function ys_prev_slide(){
|
|
gotoSlide(ys_slider_no - 1, true);
|
|
clearInterval(timer);
|
|
timer = setInterval(function(){gotoSlide("timer_increase", false);}, 10000);
|
|
}
|
|
|
|
function ys_next_slide(){
|
|
gotoSlide(ys_slider_no + 1, false);
|
|
clearInterval(timer);
|
|
timer = setInterval(function(){gotoSlide("timer_increase", false);}, 10000);
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
var ys_slide = $(".ys-slide").get(0);
|
|
$(ys_slide).css("display", "table");
|
|
$($(".ys-page-nav > span").get(0)).addClass("ys-active");
|
|
timer = setInterval(function(){gotoSlide("timer_increase", false);}, 10000);
|
|
}); |