CSS-Tricks / MovingBoxes

Simple horizontal slider which grows up the current box when it's in focus (image, title & text) and back down when it's not in focus.
http://css-tricks.github.io/MovingBoxes/
GNU Lesser General Public License v3.0
280 stars 147 forks source link

Add panels to left #109

Closed j69 closed 1 year ago

j69 commented 11 years ago

Hello! i try to add some more panels before the first slide

completed   : function(){
    //back button click
    if ( $('div.node:first').hasClass('current') ){
        ListOfMyPanels.prepend(NewPanels);
    };
}

but movingboxes need to recalculate: base.totalPanels and curPanel=curPanel+quanity of new items.

new pannels add, but then its scrolling right to current panel how can i remove these scroll?

Mottie commented 11 years ago

It doesn't look like you're updating the MovingBoxes plugin. Also, if you're adding panels in front, you'll need to change the current panel number. Try this (untested):

completed : function(e, slider, tar){
    // back button click
    if ( tar === 1 ){
        listOfMyPanels.prepend(newPanels);
        slider.curPanel += newPanels.length; // assuming newPanels is a jQuery object
        slider.update(); // tell MovingBoxes that there are new panels.
    }
}

This may not look very pretty because you'll be adding new panels to the left after the slider has finished moving. And it will add panels no matter which direction you go to get to it (if wrap is true). I would be better to use the initChange callback, but currently there isn't any way to change the target panel... I'll work on fixing that.

Update: actually, now that I've thought about it, calling an update in the initChange function would cause an infinite loop, so bad idea! I think we're stuck with the code above for now =(.