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