germanysbestkeptsecret / Wookmark-jQuery

A jQuery plugin to create a dynamic, multi-column layout.
MIT License
2.64k stars 759 forks source link

One special situation that $('#container').trigger('refreshWookmark') does not work. I have already resolved. It may help you. #231

Open feng9017 opened 7 years ago

feng9017 commented 7 years ago

Thank the author for contributing this plugin! I appreciate it that the author make so much effort to this little and helpful one! I like it ! I am dealing a bug .

function collapse(element) {
        if ($(element).hasClass("collapsed")) {
            $(element).removeClass("collapsed")
            $(element).addClass("collapse")
            $(element).html("fold")
            $(element).siblings(".duplicatefriend.toCollapse").fadeIn();
        } else {
            $(element).removeClass("collapse")
            $(element).addClass("collapsed")
            $(element).html("unfold")
            $(element).siblings(".duplicatefriend.toCollapse").fadeOut();
        }
        $('#searchTable').trigger('refreshWookmark');
    }

When the 'element' has class 'collapsed', click it. $('#searchTable').trigger('refreshWookmark') ;" works normally. But when the 'element' has html 'unfold', click it. $('#searchTable').trigger('refreshWookmark') ;" does not work.

I check the code careful . Finally find that the element's attribute "data-wookmark-height" doesn't change when I click it which hasn't class "collapsed". But it's strange that the element's attribute "data-wookmark-height" changes when I click it which has class "collapsed". I don't have enough time to check the source code. I guess the attribute "data-wookmark-height" is relevant to "refreshWookmark" working or not. At last I realize that the functions "fadeIn" and "fadeOut" working needs some time. This may cause "refreshWookmark" couldn't detect the change to the item. So I change "fadeIn" and "fadeOut" to "show" and "hide". It works finally. But this cannot answer Why "refreshWookmark" when the element has function "fadeIn" works normally. I expect that the author or others could make some response to me! It cannot be better any more that if our author make change in the next version.

Sebobo commented 7 years ago

Hi,

try running refreshWookmark in the next rendered frame. Either with setTimeout or requestAnimationFrame. That could perhaps help.

Or you can maybe also hide and show your other elements with css instead of jQuery, as jQuery changes more than only the opacity during the animation.