html - What code should I write for the reverse $(window).scroll function in jquery for scrolling upwards? -
i find code window scroll function , appended code, working great when scrolling down i.e. have image fading out while scrolling down, when scroll again, image absent because of previous effect.
so plz me this.
html part:-
<div id="blog"> <img src="trans_blog.png">//i want image fade in , out. </div>
jquery part:-
$(document).ready(function(){ $("#blog img").fadein(2000); $(window).scroll(function(){ $("#blog img").fadeout("slow"); }); });
this code should trick. fadeout element goes out of view, , fadein comes back
$(window).scroll( function(){ $('#blog img').each( function(i){ var top_of_window = $(window).scrolltop(); var this_bottom = $(this).position().top + $(this).height(); if(top_of_window > this_bottom){ $(this).fadeout(); } else { $(this).fadein(); } });
Comments
Post a Comment