-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
73 lines (66 loc) · 2.23 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$(document).ready(function(){
$('.next').on('click', function(){
var $this = $(this);
var currentImg = $('.active');
var nextImg = currentImg.next();
if(nextImg.length){
currentImg.removeClass('active fadeIn animated').css('z-index', -10);
nextImg.addClass('active fadeIn animated').css('z-index', 10);
}else{
nextImg = currentImg.parent().children().first();
currentImg.removeClass('active fadeIn animated').css('z-index', -10);
nextImg.addClass('active fadeIn animated').css('z-index', 10);
}
if(nextImg.is("video")){
nextImg[0].play();
nextImg[0].muted = false;
nextImg[0].onended = function () {
$this.click();
}
}else{
setTimeout(function () {
$this.click();
},3000)
}
if(currentImg.is("video")){
//stop video sebelumnya kemudian pindah
currentImg[0].pause();
currentImg[0].currentTime=0;
}
});
$('.prev').on('click', function(){
var $this = $(this);
var currentImg = $('.active');
var prevImg = currentImg.prev();
if(prevImg.length){
currentImg.removeClass('active fadeIn animated').css('z-index', -10);
prevImg.addClass('active fadeIn animated').css('z-index', 10);
}else{
prevImg = currentImg.parent().children().last();
currentImg.removeClass('active fadeIn animated').css('z-index', -10);
prevImg.addClass('active fadeIn animated').css('z-index', 10);
}
if(prevImg.is("video")){
prevImg[0].play();
prevImg[0].muted = false;
prevImg[0].onended = function () {
$this.click();
}
}else{
setTimeout(function () {
$this.click();
},3000)
}
if(currentImg.is("video")){
//stop video sebelumnya kemudian pindah
currentImg[0].pause();
currentImg[0].currentTime=0;
}
});
autoplay();
});
function autoplay(){
setTimeout(function () {
$(".next").click();
},"3000");
}