2013-04-26 47 views
0

嗨,大家好,你能帮我编辑这里的代码。我希望效果是可点击的,而不是悬停效果。砌体柱移位调整

http://isotope.metafizzy.co/custom-layout-modes/masonry-column-shift.html

这是当前的代码:

$container.find('.shifty-item').hover(
    function() { 
    $(this).css({ height: "+=100" }); 
    // note that element is passed in, not jQuery object 
    $container.isotope('shiftColumnOfItem', this); 
    }, 
    function() { 
    $(this).css({ height: "-=100" }); 
    $container.isotope('shiftColumnOfItem', this); 
    } 
); 

我试图使用bind( '点击',功能),但它不工作。还尝试添加一个CSS类,但这并不能解决问题ethier。

回答

1

从代码和documentation悬停有两个函数/处理程序。

$(selector).hover(handlerIn, handlerOut)

为了改变这种点击,其中只有一个,你需要在悬停以“模拟”两种状态。

$container.find('.shifty-item').click(function({ 
    if($(this).hasClass('active')) 
    { 
     $(this).css({ height: "-=100" }); 
     $container.isotope('shiftColumnOfItem', this); 
     $(this).addClass('active'); 
    } 
    else 
    { 
     $(this).css({ height: "+=100" }); 
     $container.isotope('shiftColumnOfItem', this); 
     $(this).removeClass('active'); 
    } 

}); 

此代码可以进一步优化,但你明白了。

+0

嗨试过你的代码,我还添加了我以前的代码,toggleClass。现在它可以工作。谢谢 – 2013-04-26 07:33:11

+0

我还有1个问题,我已将'css'更改为'animate'。虽然它不能正常工作。我已经尝试加入 '-webkit-transition:所有0.6s easy-in 0.2s' '-moz-transition:所有0.6s easy-in 0.2s' '-o-transition:0.6s所有-in 0.2s' '-ms-transition:0.6s ease-in 0.2s' 'transition:0.6s ease-in 0.2s' 但是仍然没有运气 – 2013-04-26 07:38:10

+0

我不是什么问题可能。如果你在老问题中找不到任何东西,请尝试打开新的q – 2013-04-26 08:07:45