jjma
1/8/2019 - 4:28 PM

Back To Top

Add back to top functionality with scrolling function

 //browser window scroll (in pixels) after which the "back to top" link is shown
\!h var offset = 300, 
  //browser window scroll (in pixels) after which the "back to top" link opacity is reduced 
 \!h   offsetOpacity = 1200,
  //duration of the top scrolling animation (in ms)
 \!h   scrollDuration = 700;
 
 // Html
 <a href="#0" class="cd-top js-cd-top">Top</a>
 
 // CSS
 
 .cd-top.cd-top--show { 
 /* the button becomes visible */ 
 visibility: visible;
 opacity: 1;
} 

.cd-top.cd-top--fade-out { 
 /* if the user keeps scrolling down, the button is out of focus and becomes less visible */ 
 opacity: .5; 
}