forked from mollytov/madness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
madness.js
65 lines (59 loc) · 1.98 KB
/
madness.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
$(window).load(function() {
// Preloader Removal //
$('#preloader').slideUp(500, function() {$(this).remove();});
// Parallax Scrolling and Scroll Binding //
function parallaxScroll(){
var scrolled = $(window).scrollLeft();
$('#layer1').css('left',(0+(scrolled*.7))+'px');
$('#layer2').css('left',(0+(scrolled*.36))+'px');
$('#layer4').css('left',(0-(scrolled*.425))+'px');
}
$(window).bind('scroll',function(e){parallaxScroll();});
// Browser Based Scrolling Parameters //
if ($.browser.mozilla) {
var t_len = 45;
var t_pix = 18;
} else if ($.browser.webkit) {
var t_len = 15;
var t_pix = 10;
} else if ($.browser.opera) {
var t_len = 15;
var t_pix = 10;
} else if ($.browser.msie) {
var t_len = 15;
var t_pix = 10;
$('.arr').remove();
$('html').css('background','#555555');
} else {
var t_len = 25;
var t_pix = 12;
}
// Manual Scrolling //
$(function(){
$("#moveL").hover(
function(){
$this = $(this);$this.data("isHovering", true);
$this.data("loopId", setInterval(function(){ if ($this.data("isHovering")) {window.scrollBy(-t_pix,0);}},t_len))
},
function(){
$this = $(this);$this.data("isHovering", false);
if ($this.data("loopId")) {clearInterval($this.data("loopId")); $this.data("loopId", false);}
}
)
$("#moveR").hover(
function(){
$this = $(this);$this.data("isHovering", true);
$this.data("loopId", setInterval(function(){ if ($this.data("isHovering")) {window.scrollBy(t_pix,0);}},t_len))
},
function(){
$this = $(this);$this.data("isHovering", false);
if ($this.data("loopId")) {clearInterval($this.data("loopId")); $this.data("loopId", false);}
}
)
});
// Automated Scrolling //
function scrollTo(newpos) {$('html,body').stop().animate({scrollLeft: newpos}, Math.abs(newpos - window.scrollX) * 2.5)}
$('#arrR').click(function () {scrollTo(9000-document.body.clientWidth);});
$('#arrL').click(function () {scrollTo(0);});
$('#stop').click(function () {$('html,body').stop().stop();});
});