Results 1 to 4 of 4

Thread: Strange jQuery animation lag

  1. #1
    Join Date
    Mar 2008
    Location
    Behind you...
    Beans
    Hidden!
    Distro
    Ubuntu 11.04 Natty Narwhal

    Post Strange jQuery animation lag

    Hi

    With the website I'm currently working on, I have this strange problem while animating some elements with jQuery.
    Instead of trying to explain what's going wrong, I've made a sample of the problem. Have a look at this: http://www.zupa.be/AnimationLag/.
    Hover one of the numbers at the upper right corner and click a link. The current green div should close smoothly and the matching div for the clicked link should open smoothly.
    This is the function that contains the animations.
    PHP Code:
    function setPanelWidth(){
        $(
    '.collapsed').animate({width:28},'fast','linear',function(){
            $(
    '.collapsed *').css('visibility','hidden');
            var 
    = $('#main').width()-2;
            $(
    '#main').children('.collapsed').each(function(){
                
    -= $(this).width()+2;
            });
            $(
    '.panel *').css('visibility','visible');
            $(
    '.panel').animate({width:w},'fast','linear');
        });

    All of you who know something about jQuery, just take a look at http://www.zupa.be/AnimationLag/, open the source, take a look at the script and make my day.

    Thanks in advance!

  2. #2
    Join Date
    Nov 2007
    Location
    Portugal
    Beans
    95
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Strange jQuery animation lag

    Well, at a glance, I don't see anything that could be causing too much trouble...

    If you use
    Code:
    $('.collapsed *').hide();
    and
    Code:
    $('.panel *').hide();
    does it work faster?


    Also, try to put

    Code:
    $('.collapsed *').css('visibility','hidden');
    var w = $('#main').width()-2;
    $('#main').children('.collapsed').each(function(){
    	w -= $(this).width()+2;
    });
    Before the

    Code:
    $('.collapsed').animate()
    to try and make it get to the resize animation faster.

  3. #3
    Join Date
    Feb 2008
    Location
    readlink("/proc/self/exe"
    Beans
    1,120
    Distro
    Ubuntu Development Release

    Wink Re: Strange jQuery animation lag

    stackoverflow.com is a good forum for JQuery questions.

    This forum is more Linux-centric.

    While it's allowed to post a Linux-unrelated question here, that doesn't mean it's a good idea.
    You'll probably get a better answer much faster, there.
    Last edited by WitchCraft; July 28th, 2010 at 12:31 PM.
    In a world without walls and fences, who needs Windows and Gates?
    Linux is like a wigwam.... no Gates, no Windows but Apache inside!
    http://www.debianadmin.com
    apt-get install libstdc++6-4.3-doc

  4. #4
    Join Date
    Mar 2008
    Location
    Behind you...
    Beans
    Hidden!
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Strange jQuery animation lag

    Thanks for the responses, I got it solved now.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •