问题
I have a slider. It animates things inside of layers. It also animates layers. So; what i want is when video layer comes sight, and it animates video itself from out of slider area; i need to do something.
This is what i have done so far. But it doesn't work.
if ($(".homeBannerVideoBg").live().is(":inView")) {
$("body").addClass("YEEHA");
}
else {
$("body").addClass("VUUHUU");
}
homeBannerVideoBg is my video element.
Can i get a hand over here ?
回答1:
https://github.com/protonet/jquery.inview
There's a great plugin, for determining when an element comes into the view when the user scrolls through the page. It takes the form of an event, so you can use a callback to perform your actions, just as you would a "click"
回答2:
try :visible
if ($(".homeBannerVideoBg").is(":visible")) {
$("body").addClass("YEEHA");
}
else {
$("body").addClass("VUUHUU");
}
来源:https://stackoverflow.com/questions/11031724/if-element-in-sight-do-something