scrollTopBtn.ftl

 1   <#-- 
 2   Macro: scrollTopBtn
 3   
 4   Description: Generates a button that appears when the user scrolls down the page, allowing them to easily scroll back to the top of the page when clicked.
 5   -->
 6   <#macro scrollTopBtn>
 7   <a href="#" id="scroll" style="display: none;"><span></span></a>
 8   <script>
 9   $( function(){ 
 10       $(window).scroll(function(){ 
 11           if ( $(this).scrollTop() > 100) { 
 12               $('#scroll').fadeIn(); 
 13           } else { 
 14               $('#scroll').fadeOut(); 
 15           } 
 16       }); 
 17       $('#scroll').click(function(){ 
 18           $("html, body").animate({ scrollTop: 0 }, 600); 
 19           return false; 
 20       }); 
 21   });
 22   </script>
 23   </#macro>