SHOW:
|
|
- or go back to the newest paste.
| 1 | //On Page Load | |
| 2 | ||
| 3 | initReturnToTop(); | |
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | //Functions below | |
| 8 | ||
| 9 | function initReturnToTop() {
| |
| 10 | var returnDiv = '\ | |
| 11 | <div id="ReturnToTop" style="position:fixed; cursor:pointer; color:#0096ff; font-size:0.7em; background-color:#171717; -moz-border-bottom-left-radius: 13px; border-bottom-left-radius: 13px; -moz-border-bottom-right-radius: 13px; border-bottom-right-radius: 13px; border:2px solid #2b2b2b; padding:2px; padding-left:10px; padding-right:10px; z-index:1000; top:-10px; right:0px;">RETURN TO TOP</div>\ | |
| 12 | '; | |
| 13 | ||
| 14 | $('body').prepend(returnDiv);
| |
| 15 | ||
| 16 | $(window).scroll(function () {
| |
| 17 | processReturnToTop(); | |
| 18 | }); | |
| 19 | ||
| 20 | $( window ).resize(function() {
| |
| 21 | processReturnToTop(); | |
| 22 | }); | |
| 23 | ||
| 24 | $('#ReturnToTop').click(function(){
| |
| 25 | $("html, body").animate({ scrollTop: 0 }, 300);
| |
| 26 | }); | |
| 27 | ||
| 28 | processReturnToTop(); | |
| 29 | } | |
| 30 | ||
| 31 | function processReturnToTop() {
| |
| 32 | var threshold = 300; //The higher the number, the further down the page the widget rolls in | |
| 33 | var curOffset = $(document).scrollTop(); | |
| 34 | if (curOffset > threshold) {
| |
| 35 | - | $('#fekcReturnToTop').animate({
|
| 35 | + | $('#ReturnToTop').animate({
|
| 36 | 'top':parseInt($('#pvpnet-bar').height()) + 'px',
| |
| 37 | },500); | |
| 38 | } else {
| |
| 39 | - | $('#fekcReturnToTop').stop(true).animate({
|
| 39 | + | $('#ReturnToTop').stop(true).animate({
|
| 40 | 'top':0, | |
| 41 | },500); | |
| 42 | } | |
| 43 | } |