forked from geniuscarrier/scrollToTop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.scrollToTop.js
39 lines (33 loc) · 919 Bytes
/
jquery.scrollToTop.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
/*!
jQuery scrollTopTop v1.0 - 2013-03-15
(c) 2013 Yang Zhao - geniuscarrier.com
license: http://www.opensource.org/licenses/mit-license.php
*/
(function($) {
$.fn.scrollToTop = function(options) {
var config = {
"speed" : 800
};
if (options) {
$.extend(config, {
"speed" : options
});
}
return this.each(function() {
var $this = $(this);
$(window).scroll(function() {
if ($(this).scrollTop() > 100) {
$this.fadeIn();
} else {
$this.fadeOut();
}
});
$this.click(function(e) {
e.preventDefault();
$("body, html").animate({
scrollTop : 0
}, config.speed);
});
});
};
})(jQuery);