1 | jQuery(document).ready( |
---|
2 | function (jQuery) { |
---|
3 | stb = jQuery('#scrolltobottom'); |
---|
4 | stt = jQuery('#scrolltotop'); |
---|
5 | stt.css('opacity', 1 ) |
---|
6 | //=================================================================== |
---|
7 | jQuery(window).resize(function (event, ui) { |
---|
8 | if (typeof (event) == 'undefined') return; |
---|
9 | scrollBottom = jQuery(window).scrollTop(); |
---|
10 | }); |
---|
11 | //=================================================================== |
---|
12 | jQuery(window).scroll(function () { |
---|
13 | if (scrollBottom < 500) { |
---|
14 | if (stt.css('opacity') > 0) { |
---|
15 | stt.stop().fadeTo(1000, 0); |
---|
16 | stt.css("display", "none"); |
---|
17 | } else { |
---|
18 | if (stt.css('opacity') == 0) { |
---|
19 | stt.stop().fadeTo(1000, 1); |
---|
20 | stt.css("display", "block"); |
---|
21 | } |
---|
22 | } |
---|
23 | } |
---|
24 | |
---|
25 | if (scrollBottom < 500) { |
---|
26 | if (stb.css('opacity') == 0) { |
---|
27 | stb.stop().fadeTo(1000, 1); |
---|
28 | stb.css("display", "block"); |
---|
29 | |
---|
30 | } |
---|
31 | } else { |
---|
32 | if (stb.css('opacity') > 0) { |
---|
33 | stb.stop().fadeTo(1000, 0); |
---|
34 | stb.css("display", "none"); |
---|
35 | |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | }); |
---|
40 | |
---|
41 | jQuery('#scrolltobottom a').click(function () { |
---|
42 | pos = jQuery('body').outerHeight(); |
---|
43 | jQuery('html, body').animate({ |
---|
44 | scrollTop: pos + 'px' |
---|
45 | }, 1000, function () { |
---|
46 | scrollBottom = jQuery(window).scrollTop(); |
---|
47 | if (stb.css('opacity') > 0) { |
---|
48 | stb.stop().fadeTo(1000, 0); |
---|
49 | stb.css("display", "none"); |
---|
50 | stt.stop().fadeTo(1000, 1); |
---|
51 | stt.css("display", "block"); |
---|
52 | } |
---|
53 | }); |
---|
54 | }); |
---|
55 | |
---|
56 | jQuery('#scrolltotop a').click(function () { |
---|
57 | |
---|
58 | pos = 0; |
---|
59 | jQuery('html, body').animate({ |
---|
60 | scrollTop: pos + 'px' |
---|
61 | }, 1000, function () { |
---|
62 | st = false; |
---|
63 | // scrollBottom = jQuery(window).scrollTop(); |
---|
64 | if (stb.css('opacity') > 0) { |
---|
65 | stt.stop().fadeTo(1000, 0); |
---|
66 | stt.css("display", "none"); |
---|
67 | stb.stop().fadeTo(1000, 1); |
---|
68 | stb.css("display", "block"); |
---|
69 | } |
---|
70 | scrollBottom = jQuery(window).scrollTop(); |
---|
71 | }); |
---|
72 | }); |
---|
73 | |
---|
74 | |
---|
75 | function gotoPos(pos) { |
---|
76 | jQuery('html, body').animate({ scrollTop: jQuery('body').outerHeight() + 'px' }, |
---|
77 | 600, function () { |
---|
78 | |
---|
79 | |
---|
80 | }); |
---|
81 | |
---|
82 | |
---|
83 | return false; |
---|
84 | } |
---|
85 | //=================================================================== |
---|
86 | jQuery(window).resize(); |
---|
87 | jQuery(window).scroll(); |
---|
88 | |
---|
89 | |
---|
90 | }); |
---|
91 | //========================================================= |
---|
92 | |
---|