Increasing your webpage usability is not that easy, you have to consider a lot of things. One of the necessary element is to be able the user to easily back to the top most of the page especially when the content is long enough. This plugin will add an elegant scroll top effect and functionality to you page in just a few line of JavaScript.

The Plugin
|
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 |
(function(jq) { jq.autoScroll = function(ops) { ops = ops || {}; ops.styleClass = ops.styleClass || 'scroll-to-top-button'; var t = jq('<div class="'+ops.styleClass+'"></div>'), d = jq(ops.target || document); jq(ops.container || 'body').append(t); t.css({ opacity: 0, position: 'absolute', top: 0, right: 0 }).click(function() { jq('html,body').animate({ scrollTop: 0 }, ops.scrollDuration || 1000); }); $(window).scroll(function() { var sv = d.scrollTop(); if (sv < 10) { t.clearQueue().fadeOut(ops.hideDuration || 200); return; } t.css('display', '').clearQueue().animate({ top: sv, opacity: 0.8 }, ops.showDuration || 500); }); }; })(jQuery); |
Plugin in use
|
1 2 3 4 5 6 7 |
$(document).ready(function(){ $.autoScroll({ scrollDuration: 2000, showDuration: 600, hideDuration: 300 }); }); |
The CSS
A CSS code required for the plugin. In your implementation you need to change the location of the image.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
.gp{ background: #666 url(arrow_up.png) center center no-repeat; width: 32px; height: 32px; color: #fff; font-family: verdana; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px; cursor: pointer; padding: 15px; margin: 5px; } |

Tags: 



Pingback: Tweets that mention A Lightweight AutoScroll to Top jQuery Plugin | INSIC DESIGNS -- Topsy.com
Pingback: Scroll para dezplazamiento hacia la parte superior de una web- ScriptandoBlog