Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 20th, 2012  |  syntax: JavaScript  |  size: 1.32 KB  |  views: 117  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $(document).ready(function(){
  2.         var $slideList = $('.quote');
  3.         var slideTimeIn = 500;
  4.         var slideTimeFloat = 3000;
  5.         var slideTimeOut = 400;
  6.         var extraSlide = 30; /* in px */
  7.  
  8.         var $mainContent = $('#mainContent').delay(500).animate({opacity: 1}, 500, startAnimation);
  9.         var viewportWidth = $mainContent.width();
  10.         var viewportHeight = $mainContent.height();
  11.         var props = [ {}, {}, {opacity:0} ];
  12.  
  13.         function startAnimation(currentSlide){
  14.                 currentSlide = (!currentSlide) ? 0 : currentSlide % $slideList.length;
  15.                 var $slide = $slideList.eq(currentSlide);
  16.                 var slideDirection = $slide.attr('data-direction');
  17.                 var gutter = null;
  18.                 $slide.css(slideDirection,0).delay(200).animate({opacity: 1}, 2000);
  19.                 // movement
  20.                 switch(slideDirection) {
  21.                         case "top":
  22.                         case "bottom":
  23.                                 gutter = viewportHeight - $slide.height();
  24.                         break;
  25.                         case "left":
  26.                         case "right":
  27.                                 gutter = viewportWidth - $slide.width();
  28.                         break;
  29.                         default:
  30.                 }
  31.                 if(gutter != null){
  32.                         props[0][slideDirection] = (gutter/2) + 'px';
  33.                         props[1][slideDirection] = (gutter/2 + extraSlide) + 'px';
  34.                         props[2][slideDirection] = gutter + 'px';
  35.                         $slide.animate(props[0], slideTimeIn, 'easeInOutQuad').animate(props[1], slideTimeFloat, 'easeOutQuint').animate(props[2], slideTimeOut, function(){
  36.                                 startAnimation(currentSlide+1);
  37.                         });
  38.                 }
  39.         }
  40. });