Search code examples
jqueryresizeeasing

resizing window/div causes div to flicker


I'm pretty sure that I should be using easing for this problem, but not certain how to implement it.

I have the following code:

function resizeBlock() {
    if ($("#blocks").width < 995) {
    $blwidth = 0;
    }
    else {
    $blwidth = ($("#blocks").width());
    $blwidth = ($blwidth + 60) - 990;
    $("#block-left").width($blwidth);
    }
};
$(window).resize(function(){
resizeBlock();
}

The div #block-left flickers/jumps when resizing the window. How would I use easing to fix this?

MTIA


Solution

  • Have a look at jQuery Animate

    $("#block-left").animate({ width: $blwidth });