Skip to content

Instantly share code, notes, and snippets.

@oclockvn
Created April 6, 2015 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oclockvn/54fa64c2df6666b620ea to your computer and use it in GitHub Desktop.
Save oclockvn/54fa64c2df6666b620ea to your computer and use it in GitHub Desktop.
<script type="text/javascript">
$(document).ready(function () {
$(window).scroll(function () {
if ($(this).scrollTop()) {
$('.your-image-class:hidden').stop(true, true).fadeIn();
}
else {
$('.your-image-class').stop(true, true).fadeOut();
}
}); // scroll-to-top
$(function () {
$('a[href*=#]:not([href=#])').click(function () {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
}); // smooth-scroll
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment