View difference between Paste ID: aHxUsL78 and
SHOW: | | - or go back to the newest paste.
1-
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
});