Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialized function problem #92

Closed
prootrash opened this issue Aug 27, 2012 · 5 comments
Closed

initialized function problem #92

prootrash opened this issue Aug 27, 2012 · 5 comments
Labels

Comments

@prootrash
Copy link

Hello,

I using Your script on my e-shop page for display products photos. I dynamically generating 'slider' content and have a sporadic problem with slider functionality. When I try load more than 3-4 photos (each photo is ~ 120KB), sometimes script doesn't run 'initialized' function. After this, left and right buttons doesn't work, only navigation dots changes my photos. When I reload page - everything working perfect. I think this is because something working wrong at photo loading time... When photos are downloaded from server and cached in web browser, I reload page and everything working correct.

@prootrash
Copy link
Author

I placed lines:

base.initialized = true;
base.$el.trigger( 'initialized.movingBoxes', [ base, base.curPanel ] );

outside:

base.change(base.curPanel, function(){

}

and now everything working very well...

My modification:

setTimeout(function(){
                base.update(false);
                base.initialized = true;
                base.$el.trigger( 'initialized.movingBoxes', [ base, base.curPanel ] );

                base.change(base.curPanel, function(){
                    // do nothing :P
                }, false);
            }, o.speed * 2 );

@Mottie
Copy link
Contributor

Mottie commented Aug 29, 2012

Thanks for taking the time to figure out the problem and working out a fix, but the two lines were within the change callback because of triggered events showing up before the plugin was initialized. I'll look into fixing this when I have some more time.

Thanks!

@visualjazz-snolan
Copy link

The code has a race condition in which the update call within the window load handler (line 60) kills the the animation call on line 356 (the animation complete function triggers the initialized event).

Moving the setTimeout code to under the update function will fix the issue like below.

$(window).load(function(){ // animate height after all images load
    base.update();

    // animate to chosen start panel - starting from the first panel makes it look better
    setTimeout(function(){
        base.change(base.curPanel, function(){
            base.initialized = true;
            base.$el.trigger( 'initialized.movingBoxes', [ base, base.curPanel ] );
        });
    }, o.speed * 2 );               
});

@Mottie
Copy link
Contributor

Mottie commented Sep 5, 2012

@visualjazz-snolan Thanks! I'll try to get this fixed in the next update (not sure when I'll get a chance, sorry).

@Mottie
Copy link
Contributor

Mottie commented Sep 18, 2012

Fixed in version 2.3. I ended up including some code to check when all images are loaded instead of using window load.

@Mottie Mottie closed this as completed Oct 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants