daily pastebin goal
5%
SHARE
TWEET

top.js

ryfan Aug 31st, 2016 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($){
  2.     // browser window scroll (in pixels) after which the "back to top" link is shown
  3.     var offset = 300,
  4.         //browser window scroll (in pixels) after which the "back to top" link opacity is reduced
  5.         offset_opacity = 1200,
  6.         //duration of the top scrolling animation (in ms)
  7.         scroll_top_duration = 700,
  8.         //grab the "back to top" link
  9.         $back_to_top = $('.cd-top');
  10.  
  11.     //hide or show the "back to top" link
  12.     $(window).scroll(function(){
  13.         ( $(this).scrollTop() > offset ) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
  14.         if( $(this).scrollTop() > offset_opacity ) {
  15.             $back_to_top.addClass('cd-fade-out');
  16.         }
  17.     });
  18.  
  19.     //smooth scroll to top
  20.     $back_to_top.on('click', function(event){
  21.         event.preventDefault();
  22.         $('body,html').animate({
  23.             scrollTop: 0 ,
  24.             }, scroll_top_duration
  25.         );
  26.     });
  27.  
  28. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top