About events in programming languages

Many programming language supports events or notifications. The basic concept is that you can subscribe to these events and the application will send you a notification or run some code when they accour, so you will have a chance to do something you may want to be done in certain points of your program. For example change the site's background when the slider switching slides.

Javascript uses callback functions

In Javascript these events commonly used with callback functions. Instead of sending and receiving notifications, you just pass an anonymous function (also known as blocks in other languages) with your own code to a function or method call as a parameter and the application will execute it when the time has come. LayerSlider uses this kind of event handling.

Events in LayerSlider

So we now by now the technique about event handling, lets see which kind of event LayerSlider has:

A simple example of a callback function

This simple example will alert the user when LayerSlider changed a slide. To do that we have to pass this function to the cbAnimStop event.

function() {
	alert('The slider switched to a new layer!');
}

What's next?

If you want to achieve something with the event callbacks, you probably instrested in our API. Please continue reading with the next section of this document.