Advertisement
Guest User

Untitled

a guest
Dec 5th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.26 KB | None | 0 0
  1. //rotation speed and timer
  2.         var speed = 3000;
  3.         var run = setInterval(rotate, speed);
  4.  
  5.         //a simple function to click next link
  6.         //a timer will call this function, and the rotation will begin :)
  7.         function rotate() {
  8.             var awardSlides = document.getElementsByClassName('awardSlider'),
  9.                 slideInner = Array.prototype.slice.call( $( awardSlides ).find('.slideInner'), 0),
  10.                 slide = Array.prototype.slice.call( $( slideInner ).find('.award'), 0),
  11.                 width = slide[0].offsetWidth,
  12.                 left_value = width * (-1);
  13.            
  14.             if ($( awardSlides ).hasClass('is-active')) {
  15.  
  16.                 //slide the item
  17.                 $( slideInner ).animate({'left': left_value}, 200, function () {
  18.                     var currentInner = Array.prototype.slice.call( $( this ));
  19.  
  20.                     //move the first item and put it as last item
  21.                     $( this ).find('.award').last().after( $( this ).find('.award').first() );
  22.  
  23.                     //set the default item to correct position
  24.                     $( slideInner ).css({'left': 0});
  25.                 });
  26.             }
  27.  
  28.             //cancel the link behavior
  29.             return false;
  30.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement