FEDERICO MARINO
posted this
09 June 2019
anchors + sliding = animation effects
Hi Christophe,
I was also looking for how to achieve this effect, and I've found a temporary workaround,
even if the implementation in Nicepage directly would be a much better solution with controls and such.
Anyway, here is the solution:
after you export to HTML,
add this line of code between the HEAD tags
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// 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;
});
} // End if
});
});
</script>
Hopefully this helps you too.
Cheers,
Federico
> anchors + sliding = animation effects
Hi Christophe,
I was also looking for how to achieve this effect, and I've found a temporary workaround,
even if the implementation in Nicepage directly would be a much better solution with controls and such.
Anyway, here is the solution:
after you export to HTML,
add this line of code between the HEAD tags
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// 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;
});
} // End if
});
});
</script>
Hopefully this helps you too.
Cheers,
Federico
Last edited 09 June 2019 by FEDERICO MARINO