Looking for assistance to create a fading effect where a logo fades out and a smaller version fades in as I scroll. The scaling aspect is currently functioning correctly on scroll (view JS Fiddle), but the fading transition needs some work, resulting in choppy animation (see JSFiddle here). Any advice on how to smooth out the fading transition would be greatly appreciated.
Javascript:
function scrollAnimation() {
if ($(window).width() > 640){
var scrollTop = $(window).scrollTop();
if (scrollTop > 50) {
$(".inner").addClass('scrolling');
setTimeout(function() {
$(".inner").removeClass('hide-logo').addClass('show-logo');
}, 500);
}
else {
$(".inner").addClass('hide-logo').removeClass('show-logo scrolling');
};
} else {
$(".inner").removeClass('show-logo scrolling');
$(".inner").addClass('hide-logo');
}
}
$(window).on('scroll resize', function () {
scrollAnimation();
});