I'm trying to create a simple fading effect with jquery. Here is the link which show the example. The problem is it seems it doesn't work properly. Why?
It's because animate chains too much when you scroll. Use code below for both lines
navbarBrandImg.stop().animate(/* your code */)
Also check this article about how bad is to use .scroll()
directly
For that purpose, use fadeIn, fadeOut jQuery effects instead.
See working example here: JSBIN
Edit the following in your code:
CSS:
img {
display: none;
position: fixed;
}
JS
if ($currWindow.scrollTop() > 100) {
navbarBrandImg.fadeIn(500);
} else {
navbarBrandImg.fadeOut(500);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.