私はanimate.jsとfullpage.jsを使用しています。私の目標は、セクションから離れてスクロールするときにslideOutLeftアニメーションを追加し、セクションを訪れたときにslideInLeftアニメーションを追加することです。fullpage.jsでクラスを削除して追加することができない
現在のコードでは、アニメーション内のスライドを削除し、スライドアウトアニメーションを適用しますが、アニメーションにスライドを再適用することはありません。 onLeave
については
$('#fullpage').fullpage({
afterLoad: function(anchorLink, index) {
$('.text').addClass('animated slideInLeft');
},
onLeave: function(index, nextIndex, direction) {
$('.text').removeClass('animated slideInLeft');
$('.text').addClass('animated slideOutLeft');
}
});
#first {
background-color: yellow;
}
#second {
background-color: blue;
}
.height {
height: 100vh;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.7.9/jquery.fullPage.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.7.9/jquery.fullPage.css" rel="stylesheet" />
<div id="fullpage">
<div class="section height" id="first">
<h2 class="text">Something1</h2>
</div>
<div class="section height" id="second">
<h2 class="text">Something2.</h2>
</div>
<div class="section height" id="third">
<h2 class="text">Something else </h2>
</div>
</div>
答えは、あなたがしたいということであれば、ダニを与え、容易に応答のための –
おかげで解決策を見つけることができ、他のユーザーのためにそれを投票してください。私はまだそれをテストする機会を持っていないが、スニペットは期待どおりに動作します。 – Tronald