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

callback on final panel #75

Closed dubdesign closed 12 years ago

dubdesign commented 12 years ago

again not an issue but a question/request.

Is it possible to trigger a function when the slider gets to the final panel (with wrap set to false)?

as an example it could open up a modal dialog box saying thank you for watching this slideshow, would you like to watch it again? I'm wanting to do something slightly different but i thought that was probably the best example to explain.

Mottie commented 12 years ago

All you need to do is use the completed callback and check the wrap option value and which panel is showing (demo):

$('#slider').movingBoxes({

    completed: function(e, slider, tar){
        if (!slider.options.wrap && tar === slider.totalPanels){
            alert('You are on the last panel');
        }
    }

});​
dubdesign commented 12 years ago

perfect, exactly what i was looking for thanks