bounceIn()
のようなCSSアニメーションや関数を使用する方法はありません、bounceInDown()
などは」jQueryのの一部ではありませんそのようなjQueryオブジェクトで使用する必要があります。 (fadeIn
は有効なjQuery関数です)
jQueryトリガでCSSアニメーションを使用するには、CSSを使用してアニメーションを定義し、次にjQueryを使用して定義クラスを切り替える必要があります。このデモでは、プロセスを示しています
$("#mainCenterBall").click (function(){
$("#ball1").addClass ("bounceInDown");
$("#ball2").fadeIn (1000);
$("#mainCenterBall").fadeOut (1000);
});
$("#resetBtn > button").click (function(){
$("div").removeAttr ("style");
$("#ball1").removeClass ("bounceInDown");
});
/*--- CSS animation stuff ---*/
.animate2sec {
animation-duration: 2s;
}
@keyframes bounceInDownKF {
0% { transform: translateY(-2000px); }
40% { transform: translateY(30px); }
80% { transform: translateY(-10px); }
100% { transform: translateY(0); }
}
.bounceInDown {
animation-name: bounceInDownKF;
}
/*--- Demo setup stuff ---*/
#container { display: flex; height: 180px; align-items: center; }
#ball1, #ball2, #mainCenterBall {
border: 2px solid gray;
display: inline-block;
margin: 0 1.5ex;
}
#ball1, #ball2 { border-radius: 35px; height: 70px; width: 70px; }
#mainCenterBall {
border-radius: 65px;
height: 130px;
width: 130px;
background: black;
color: white;
display: flex;
align-items: center;
cursor: pointer;
}
#ball1 { background: green;}
#ball2 { background: red; display: none; }
.centerElm { margin: 0 auto; }
#resetBtn { width: 90%; text-align: center; }
#resetBtn > button { cursor: pointer; margin: 0 auto; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div id="container">
<div class="animate2sec" id="ball1"></div>
<div id="mainCenterBall"><span class="centerElm">Click me</span></div>
<div id="ball2"></div>
</div>
<div id="resetBtn"><button>Reset</button></div>
注こと:
- jQuery has a different animation interface。
- ありますきちんとbunch of predefined CSS
@keyframes
and CSS styles at Animate.css on GitHub
あなたはおそらく唯一のjQueryのではなく、jQueryのUIを持っています。 – Chris
実際、JQuery UIは有効になっていません。 – Sergi
機能していない機能に関するドキュメントがどこにあるか教えてください。 'fadeIn'はjQueryのメソッドhttp://api.jquery.com/fadein/です。たとえば、「bounceIn」は、http://api.jquery.com/?s=bounceinではありません。 –