Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- var current = 0;
- function previousIndex() {
- var previous = current - 1;
- if (previous == -1) {
- previous = $(".tour-panel").size() - 1;
- }
- return previous;
- }
- function nextIndex() {
- var next = current + 1;
- if (next == $(".tour-panel").size()) {
- next = 0;
- }
- return next;
- }
- function removeClasses() {
- $(".tour-panel").each(function(index) {
- if (index != current) {
- $(this).removeClass("active-tour fadeInRight fadeInLeft fadeOutRight fadeOutLeft");
- }
- })
- }
- function nextElement() {
- removeClasses();
- $($(".tour-panel")[current]).addClass("fadeOutLeft");
- current = nextIndex();
- setTimeout(function() {
- $($(".tour-panel")[current]).addClass("active-tour fadeInRight");
- }, 50);
- setTimeout(function() {
- $($(".tour-panel")[previousIndex()]).removeClass("active-tour fadeOutLeft");
- }, 750);
- console.log(current);
- }
- function previousElement() {
- removeClasses();
- $($(".tour-panel")[current]).addClass("fadeOutRight");
- current = previousIndex();
- setTimeout(function() {
- $($(".tour-panel")[current]).addClass("active-tour fadeInLeft");
- }, 50);
- setTimeout(function() {
- $($(".tour-panel")[nextIndex()]).removeClass("active-tour fadeOutRight");
- }, 750);
- }
- $('.slideshow-timeline a').click(function() {
- var target_id = $(this).attr('href');
- removeClasses();
- $($(".tour-panel")[current]).addClass("fadeOutLeft");
- current = parseInt(target_id.split('-')[1]) || 0; // change here
- setTimeout(function() {
- $($(".tour-panel")[current]).addClass("active-tour fadeInRight");
- }, 50);
- });
- Mousetrap.bind('left', previousElement);
- Mousetrap.bind('right', nextElement);
- $(".previous").click(previousElement);
- $(".next").click(nextElement);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement