gpt4 book ai didi

Javascript 与 jQuery 或 Javascript 一起淡入

转载 作者:行者123 更新时间:2023-12-02 15:45:59 25 4
gpt4 key购买 nike

我怎样才能让Javascript像这样淡入淡出: http://www.bewerberfilm.com

视频从左侧和右侧淡入。视频上方的文本框以不同的第二设置淡入。我怎样才能意识到这一点?谁能告诉我或帮助我吗?我没有 JS/Jquery 经验,但我想学习该语言。

最佳答案

您可以向 scroll 事件添加监听器,如下所示:

$(document).ready(function() {
var element = $('#MyElement');

var running = false;

$(window).scroll(function() {
console.log(element.position());
if (element.position().top <= $(window).scrollTop() + $(window).innerHeight() && !running) {
console.log("Triggering animation");
running = true;
element.removeClass().addClass('fadeInLeftBig animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$(this).removeClass();
});
}
});
});
#MyElement {
height: 40px;
clear: both;
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>
adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>adsada
<br/>
</p>
<div id="MyElement"></div>

这里是一个工作 fiddle ,整个 css 对于 StackOverflow 片段来说太大了:http://jsfiddle.net/df19qumg/

关于Javascript 与 jQuery 或 Javascript 一起淡入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32198581/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com