Utkarsh Bhimte
Utkarsh Bhimte

Reputation: 335

jQuery Fade Out on Scroll not working

I am using this to fade out a div on scroll but its not working, 600 is the offset of the div. I cant figure out why this is not working.

$(window).scroll(function(){

wScroll = $(this).scrollTop();

 $('.hack').css({
    'transform' : 'translate(0px , ' + wScroll/2  +'%)',
    'opactiy' : 1 - (wScroll/600)
 });

});

Upvotes: 0

Views: 221

Answers (1)

Ryan
Ryan

Reputation: 989

$(window).scroll(function () {
var scrollTop = $(window).scrollTop();
var height = $(window).height();
$('.logo_container, .slogan').css({
    'opacity': ((height - scrollTop) / height)
});
});

Demo

Upvotes: 2

Related Questions