I have a pure CSS3 slideshow of 4 videos which work fine. I'm using the following code to navigate through the slideshow however because I'm telling it to go left or right 25% when the animation of the slideshow resumes it thinks that there are slides that need to be displayed based on the number of times you click 'next'.
For example, if i have clicked next through 2 slides then as soon as the slideshow resumes instead of going back to the first slide it shows 2 blank slides.
I'm struggling to find a solution to linking the two so that you can navigate through the slides but also so it knows the current position in the keyframes.
If anyone could point me in the right direction i would be so grateful.
CSS
#carousel {
width: 100%;
overflow: hidden;
}
@-webkit-keyframes slider {
0%, 20%, 100%{ left: 0 }
25%, 45%{ left: -100% }
50%, 70%{ left: -200% }
75%, 95%{ left: -300% }
}
@-moz-keyframes slider {
0%, 20%, 100%{ left: 0 }
25%, 45%{ left: -100% }
50%, 70%{ left: -200% }
75%, 95%{ left: -300% }
}
@keyframes slider {
0%, 20%, 100%{ left: 0 }
25%, 45%{ left: -100% }
50%, 70%{ left: -200% }
75%, 95%{ left: -300% }
}
#carousel .video-list, #descriptionCarousel .description-list {
position: relative;
width: 400%;
height: 100%;
left: 0;
top: 0;
bottom: 0;
animation: slider 60s cubic-bezier(.93,.11,.32,.94) infinite;
-webkit-animation: slider 60s cubic-bezier(.93,.11,.32,.94) infinite;
-moz-animation: slider 60s cubic-bezier(.93,.11,.32,.94) infinite;
-o-animation: slider 60s cubic-bezier(.93,.11,.32,.94) infinite;
-ms-animation: slider 60s cubic-bezier(.93,.11,.32,.94) infinite;
animation-delay: 4.6s;
-webkit-animation-delay: 4.6s;
-moz-animation-delay: 4.6s;
-ms-animation-delay: 4.6s;
-webkit-transition: -webkit-transform 1s cubic-bezier(.93,.11,.32,.94);
transition: -transform 1s cubic-bezier(.93,.11,.32,.94);
}
#carousel .video-list li, #descriptionCarousel .description-list li {
position: relative;
width: 25%;
height: 100%;
overflow: hidden;
display: inline-block;
float: left;
}
JS
$(function () {
var position = 0;
$('#next').on('click', function (e) {
e.preventDefault();
position = (position - 25) % 100;
$('#carousel .video-list').css('-webkit-transform', 'translateX(' + position + '%)');
$(".video-list, #timeline, .description-list").css({"animation-play-state": "paused",
"-webkit-animation-play-state": "paused"});
});
$('#previous').on('click', function (e) {
e.preventDefault();
position = (position + 25) % 100;
position = (position > 0) ? -75 : position;
$('#carousel .video-list, #descriptionCarousel .description-list').css('-webkit-
transform', 'translateX(' + position + '%)');
$(".video-list, #timeline, .description-list").css({"animation-play-state": "paused",
"-webkit-animation-play-state": "paused"});
});
});