【问题标题】:JQuery Cycle Plugin - Variable / Resize HeightJQuery Cycle Plugin - 可变/调整高度
【发布时间】:2012-07-13 13:03:07
【问题描述】:

我一直在尝试重新创建类似于 http://www.brianrea.com/Progress-drawings 上使用的循环插件的东西。

我基本上需要分页,并要求容器根据图像的高度调整大小/调整其高度,并带有流畅的动画。宽度是静态的。

尝试查看插件的文档,但它不是很具体,并且没有关于此功能的演示(我可以找到)。

谁能指出我正确的方向?

我现在有一些事情,例如:

$('#feature').cycle({ 
    fx:     'scrollHorz', 
    prev:   '#previous', 
    next:   '#next',
    width:   660,
    after:   onAfter, 
    timeout: 0 
});

function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    $('#previous')[index == 0 ? 'hide' : 'show']();
    $('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}

【问题讨论】:

    标签: javascript jquery jquery-plugins cycle jquery-cycle


    【解决方案1】:

    我认为您可以使用 before 回调函数和一点 css 过渡魔法来做到这一点:

    http://jsfiddle.net/vPJCv/2/

    HTML

    <a href="#" id="prev">&larr;</a>
    <a href="#" id="next">&rarr;</a>
    
    <div id="slideshow">
     <img src="http://flickholdr.com/500/200/sea,sun/1">
     <img src="http://flickholdr.com/500/400/sea,sun/2">
     <img src="http://flickholdr.com/500/500/sea,sun/3">
     <img src="http://flickholdr.com/500/300/sea,sun/4">
     <img src="http://flickholdr.com/500/400/sea,sun/5">
    </div>​
    

    JS

    $(document).ready(function(){
    
        $('#slideshow').cycle({
            before : function(currSlideElement, nextSlideElement){
              $('#slideshow').css('height', $(nextSlideElement).height()+'px');
            },
            timeout : 0,
            prev : $('a#prev'),
            next : $('a#next')
        });
    
    });
    

    CSS

    #slideshow{
      border-bottom: 2px solid #000;
      padding: 10px;
      -webkit-transition: all .2s ease;
         -moz-transition: all .2s ease;
              transition: all .2s ease;
    }​
    

    【讨论】:

    • 干杯伙伴!发挥了魅力——绝对的传奇!
    猜你喜欢
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-06
    • 2012-01-25
    • 2012-10-25
    相关资源
    最近更新 更多