Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript AnythingSlider onInitialized bug?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #39758
    Frantiq
    Member

    Hi.

    I have a slider where every single slide has a (hidden) div with text in it. On “onSlideComplete” I switch text in a div outside of the actual slider by $(‘#slider .activePage .caption’).html().

    I want to do the same thing on “onInitialized”. onInitialized is supposed to be “Callback when the plugin finished initializing”.

    But it’s not working. The class “activePage” is not set on onInitialized. BUT here’s the strange thing: if I add a setTimeout(function () {
    My code
    }, 1);
    it works. Am I doing something wrong with the callback or is this a bug?

    #109726
    Mottie
    Member

    Hi Frantiq!

    It sounds like [this demo](http://jsfiddle.net/Mottie/ycUB6/34/) might be doing what you want. I wouldn’t recommend using the `activePage` class since it isn’t added until have the slide has completed animation.

    var updateCaption = function(slider){
    var cap = slider.$currentPage.find(‘.caption’).html();
    $(‘#current-caption’)
    .html(cap)
    .fadeIn(200);
    };

    $(‘#slider’).anythingSlider({

    // *********** Callbacks ***********
    // Callback when the plugin finished initializing
    onInitialized: function(e, slider) { updateCaption(slider); },

    // Callback before slide animates
    onSlideBegin: function(e, slider) {
    $(‘#current-caption’).fadeOut(200);
    },

    // Callback when slide completes – no event variable!
    onSlideComplete: function(slider) { updateCaption(slider); }

    });​

    #109747
    Frantiq
    Member

    Thanks Mottie, that worked like a sharm :)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.