フィギュアの.slider-active
ときにアクティブなクラスを持つjQueryスライダーに取り組んでいます。mouseEnter
.slider-imgcontainer
このようにして、私と私のフィグキャプションをクールな効果でアニメーション化したいと思います:
変更の際.slideractive
、前のオブジェクトは の幅.slider-imgcontainer
を 250px に、 と の後にwidth
をpadding
0figcaption
に縮小する必要があります。 の を縮小するwidth
とfigcaption
、テキストが高すぎたので、 と を使用.hide
し.show
てこれを修正しました。
その後、スライダーが機能し始めますが...マウスが複数の図の上に移動すると、それらすべてがアニメーション化されます。これを修正しようとしましたが、解決策が見つかりません ( .clearQueue()
etを使用.stop()
)。
結果:現在のスライダー
メインのアニメーション コード:
$(document).ready(function(){
var GLOBAL = {
window:$(window),
slider:$('.slider-work'),
container:$('#container'),
figure:$("figure")
}
/********* SLIDER MAIN *************/
// INIT LARGEUR ---
GLOBAL.slider.width($(".slider-work img").size() * 250 + 900);
// save width of figcaption in attr to animate them after (no auto animate)
GLOBAL.slider.find("figcaption").each(function(i) {
var t = $(this);
if(!t.parent().hasClass("slider-active"))
t.hide();
t.attr("largeur", t.width());
});
// hover
GLOBAL.slider.children("figure").mouseenter( function () {
var oldActive = $(".slider-active");
var thiss = $(this);
oldActive.removeClass("slider-active");
thiss.addClass("slider-active");
oldActive.find("figcaption").animate({
width: 0,
padding: 0
}, 220, 'linear', function() {
oldActive.find(".slider-imgcontainer").animate({
width : 250
}, 400, 'linear', function() {
// Animation de l'ancien active fini , alors :
//$(".slider-imgcontainer").removeAttr("style");
thiss.removeAttr("style").children(".slider-imgcontainer").animate({
width : 400
}, 400, 'linear', function(){
var largeurFigcaption = thiss.find("figcaption").show().attr("largeur");
thiss.find("figcaption").animate({
width : largeurFigcaption,
padding : " 0 20px 20px 20px"
}, 220, 'linear', function(){
});
});
});
});
});
// END MouseEnter
//End ready
});
そして、スライダーをデバッグするための私のコード
GLOBAL.slider.children("figure").mouseout( function () {
var thiss = $(this);
//$("#title span").append(" toto");
var myChildrenBehave = GLOBAL.slider.filter(function() {
var filtered = $(this).children().is(":animated");
return filtered;
});
myChildrenBehave.clearQueue().stop();
});
私はすべての考えを受け入れます:)