如何将this
元素传递给myfunc()
,然后使用它来控制flex-container-column
中的各个灵活项?如果我正在听一个简单的事件,这很容易,但使用航路点会让它变得有点困难。
现在,我可以成功地将direction
参数(?,idk所谓的内容)传递给myfunc()
但是所有的flex项目都应用于动画,因为在{{1}内},目标元素被硬编码为myfunc()
。我想做的是:
从:
$(".test-class")
为:
$(".test-class").addClass("animated fadeInDown");
谷歌搜索没有帮助,因为所有答案都不使用航点。 这是代码簿
- 我在这里提供代码以防万一。
myscripts.js
$(this).addClass("animated fadeInDown");
HTML
$(document).ready(function(){
$('.test-class').waypoint(function(direction) {
myfunc(direction);
},{offset:'25%'});
function myfunc(direction){
if(direction === "down"){
$(".test-class").addClass("animated fadeInDown");
setTimeout(function(){
$(".test-class").removeClass("animated fadeInDown"); }, 2000);
}
else{
//do nothing
}
}
});
CSS
<body>
<div>
<ul class="header flex-container">
<li class="nav flex-item">About</li>
<li class="nav flex-item">Links</li>
<li class="nav flex-item">Contact</li>
</ul>
</div>
<div class="content flex-container">
<div class="sidebar flex-item">Sidebar</div>
<div class="main flex-item">
<div class="flex-container-column">
<p class="flex-item test-class"> This is the content</p>
<p class="flex-item test-class"> This is the content</p>
<p class="flex-item test-class"> This is the content</p>
<p class="flex-item test-class"> This is the content</p>
<p class="flex-item test-class"> This is the content</p>
<p class="flex-item test-class"> This is the content</p>
<p class="flex-item test-class"> This is the content</p>
<p class="flex-item test-class"> This is the content</p>
</div>
</div>
<div class="sidebar flex-item">Sidebar</div>
</div>
</body>
<footer>footer here</footer>