私の jQuery 関数によって生成されたアニメーションは不安定で、jquery.easing を追加するなど、さまざまな SO ソリューションを調べてきましたが、うまくいきませんでした。問題は各 div の iframe ですか?
アニメーションを滑らかにする方法についてのアイデアはありますか? 私の基本的なトグル機能は最良の方法ですか?
JSFiddle: http://jsfiddle.net/gwLcD/8/
基本的なマークアップは以下のとおりで、ページ上で何度も繰り返されます (各 "videotoggle" div の間にテキストのブロックがあります)。
<div class="videotoggle">
<p><h2 class="entry-title">View a few minutes of the (title) video </h2></p>
<div class="videoblock">
<iframe width="560" height="315" src="http://www.youtube.com/embed/????????"
frameborder="0" allowfullscreen></iframe>
</div></div>
そして機能:
$(document).ready(function(){
$(".videoblock").hide(); //closes all divs on first page load
$(".entry-title").click(function() {
$this = $(this); //this next code only allows one open div at a time
$content = $this.closest('.videotoggle').find(".videoblock");
if (!$this.is('.active-title')) {
$('.active-title').removeClass('active-title');
$this.addClass('active-title');
$(".videoblock:visible").slideToggle(400); //slide toggle
$content.slideToggle(400);
}
});
});