when updating location.hash in Chrome the jQuery animation "freezes" for a second

Posted by ubunut on Stack Overflow See other posts from Stack Overflow or by ubunut
Published on 2010-04-08T08:39:56Z Indexed on 2010/04/08 8:43 UTC
Read the original article Hit count: 372

I'm trying to create a sort of "virtual gallery". I'm using Coda Slider 2.0 & jQuery v1.4.2

It behaves perfectly in IE, FF & Safari, but Chrome seems to reload/hang for a second when setting location.hash. This causes the jQuery animation to freeze for a second :S

Example: http://hardyernst.dk/gallery.html try clicking on the navigation links above the pictures.

The jQuery code that is being executed when clicking a navigation link:

        $('#coda-nav-' + sliderCount + ' a').each(function(z) {
        // What happens when a nav link is clicked
        $(this).bind("click", function() {
            offset = -(panelWidth*z);
            navClicks++;
            $(this).addClass('current').parents('ul').find('a').not($(this)).removeClass('current');
            alterPanelHeight(z);
            currentPanel = z + 1;
            $('.panel-container', slider).stop().animate({ left: offset }, settings.slideEaseDuration, settings.slideEaseFunction, function(){
            if (!settings.crossLinking) { return false; } // Don't change the URL hash unless cross-linking is specified
            });
        });
    });

if I add

return false;

at the end of the function. The animation will slide smoothly :)... BUT as you might have guessed the location.hash value remains unchanged :(

I have tried setting the location.hash earlier in the function alas it did not change the behavior in Chrome

Would be immensely grateful for any help :)

Regards Ubunut

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about google-chrome