本文介绍了如果看到元素,做点什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滑块.它为层内的事物设置动画.它还为图层设置动画.所以;我想要的是当视频层出现时,它会从滑块区域之外对视频本身进行动画处理;我需要做点什么.

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 是我的视频元素.

homeBannerVideoBg is my video element.

我可以在这里帮忙吗?

推荐答案

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"

这篇关于如果看到元素,做点什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:40