开发者

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

开发者 https://www.devze.com 2023-02-17 08:50 出处:网络
I am making a site using coda slider, the panelWidth I\'d like to be set depending on the image width in the div.

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

精彩评论

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

关注公众号