如果在眼前,做点什么 [英] if element in sight, do something

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

问题描述

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

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"

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆