简体   繁体   English

jQuery:自定义水平手风琴宽度问题

[英]jQuery: custom horizontal accordion width issue

Im trying to create a custom horizontal accordion style showcase. 我试图创建一个定制水平手风琴风格的展示。 In terms of actual functionality, i have the framework (which can be seen here): 在实际功能方面,我有框架(可以在这里看到):

http://www.jsfiddle.net/adrianjacob/UdUus/ http://www.jsfiddle.net/adrianjacob/UdUus/

However my main bug bear (and the clients) is that if you look at the right hand side, there is always slight movement/flickering as the widths animate up and down. 然而,我的主要bug(和客户端)是,如果你看右手边,随着宽度上下动画,总会有轻微的移动/闪烁。

Ideally I want it to appear smooth so only the opening/closing lists have movement. 理想情况下,我希望它看起来平滑,所以只有开始/结束列表有移动。

ANy advice would be much appreciated. 任何建议将不胜感激。

A. 一种。

Use the animate function's step (it's not well documented)... I've updated the demo 使用animate函数的step (没有详细记录)...我已经更新了演示

var panels = $('#promo li');

panels.hoverIntent(

function() {
    if (!$(this).is('.expanded') && !panels.is(':animated')) {
        $(this).animate({
            width: 200
        }, {
            // width is the calculated width, ani is the animation object
            step: function(width, ani) {
                var w = Math.floor(width);
                // use 250 so we end up with 50 as the reduced size
                $('.expanded').css('width', (250 - w) + 'px');
                $(ani.elem).css('width', (200 - w) + 'px');
            },
            duration: 500,
            complete: function() {
                panels.removeClass('expanded');
                $(this).addClass('expanded');
            }
        });
    }
}, function() {});

A similar method is used in the Kwicks plugin. Kwicks插件中使用了类似的方法。

You could try this plugin which may have figured out the bug. 你可以尝试这个可能已经找出错误的插件 The example provided was too showy to actually tell. 提供的示例太过华丽而无法实际讲述。

Have you played around with jQuery UI easings? 你玩过jQuery UI缓动吗?

You can also try to stop the event just when the div is opening. 您也可以尝试在div打开时停止事件。

The website with explanation is: http://api.jquery.com/stop/ 有解释的网站是: http//api.jquery.com/stop/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM