开发者

can I make the panel width the width of the image inside the coda slider?

I am making a site using coda slider, the panelWidth I'd like to be set depending on the image width in the div.

$(".panel").each(function(){
                        var imageWidth = $开发者_运维知识库(this).find("img").width()+1;
                        $(this).width(imageWidth);

                    });

Any ideas?


One way for your problem is to modify the coda slider plugin. I didn't find a out of the box way to do this with the plugin. Here is a rough way to do what you want, look at it as a little inspiration. I modified the alterPanelHeight function, so if you set the autoHeight option, it will alter the width, too. Note: The modification will not alter the width on load, the first modification will take place after the first scroll...

    function alterPanelHeight(x) {
        if (settings.autoHeight) {
            newSliderWidth = $('.panel:eq('+x+')').find('img').width();
            panelHeight = $('.panel:eq(' + x + ')', slider).height()
            slider.animate({ height: panelHeight, width: newSliderWidth }, settings.autoHeightEaseDuration, settings.autoHeightEaseFunction);

        };
    };      
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜