Is there a way to make an image appear and disappear as the user scrolls by using the .animate() method? I have attempted to implement it, but unfortunately, it seems quite slow and sometimes the image does not reappear when scrolling back to the top. Take a look at this demo: DEMO
$(window).scroll(function(){
if($(this).scrollTop() > 50){
$('.rot-frog').animate({
'bottom': '-80',
'right': '-40'
}, 500);
}else{
$('.rot-frog').animate({
'bottom': '-12',
'right': '-6'
}, 500);
}
});
I have checked the console for errors and experimented with different CSS properties, but the delay persists. It appears that the issue lies in the combination of .scroll() and .animate(). Despite my efforts to research similar problems, I have not been able to find a solution. Can someone help me understand why this is happening?