/** ANIMAZIONE PER LO SCROLL SU E GIU DELLA PAGINA WEB **/ $(document).ready(function(){ // Add scrollspy to $('body').scrollspy({target: ".navbar", offset: 50}); // Add smooth scrolling on all links inside the navbar $("#navigazione a").on('click', function(event) { // Prevent default anchor click behavior event.preventDefault(); // Store hash var hash = this.hash; // Using jQuery's animate() method to add smooth page scroll // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area $('html, body').animate({ scrollTop: $(hash).offset().top }, 800, function(){ // Add hash (#) to URL when done scrolling (default click behavior) window.location.hash = hash; }); }); });$(document).ready(function(){ // Add scrollspy to $('body').scrollspy({target: ".navbar", offset: 50}); // Add smooth scrolling on all links inside the navbar $("#navigazione a").on('click', function(event) { // Prevent default anchor click behavior event.preventDefault(); // Store hash var hash = this.hash; // Using jQuery's animate() method to add smooth page scroll // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area $('html, body').animate({ scrollTop: $(hash).offset().top }, 800, function(){ // Add hash (#) to URL when done scrolling (default click behavior) window.location.hash = hash; }); }); }); /** bottone back-to-top **/ /** NOTA BENE: E' INDIPENDENTE DAL PRECEDENTE SCRIPT!**/ $('body').prepend('Torna su'); var amountScrolled = 200; $(window).scroll(function() { if ( $(window).scrollTop() > amountScrolled ) { $('a.back-to-top').fadeIn('slow'); } else { $('a.back-to-top').fadeOut('slow'); } }); $('a.back-to-top').click(function() { $('html, body').animate({ scrollTop: 0 }, 700); return false; });