I've added a script I found on here. It works a treat. However, I've come stuck when trying to apply a fade effect to it. At the minute it just cuts out.
script type="text/javascript">
$(document).ready(function() {
$(window).scroll(function () {
var height = $('body').height();
var scrollTop = $('body').scrollTop();
var opacity = 1;
if(scrollTop > 400) {
opacity = 0;
}
$('.social').css('opacity', opacity);
});
});
</script>
EDIT: I tied this and it works. Thanks so much guys:
<script type="text/javascript">
$(window).scroll(function() {
// The social div
var $socialDiv = $('.social');
//Get scroll position of window
var windowScroll = $(this).scrollTop();
//Slow scroll of social div and fade it out
$socialDiv.css({
'margin-top' : - (windowScroll / 3) + "px",
'opacity' : 1 - (windowScroll / 550)
});
});
</script>
You should use .animate() or .fadeTo() for that effect.
Using .css('opacity', opacity);
will make make your element to disappear abruptly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With