Turn Events

From Turn.js Documentation
Jump to navigation Jump to search

The events allow you to define behaviors to specific moments. It’s possible to define events in two different ways:

1. Using the when key of options

While adding event listeners, it will require to add the listeners before the constructor creates the flipbook. For example:

$("#flipbook").turn({when: {
	turning: function(event, page, pageObject) {
		// Implementation
	}
}
});

2. Using bind

jQuery provides a bind function in order to add listeners to elements. You can use bind to add as many listener as you need for an event. For example:

$("#flipbook").bind("turning", function(event, page, pageObject) {
	// Implementation
});

If the option prefix is true, the method must include the prefix turn. For example:

$("#flipbook").bind("turn.turning", function(event, page, pageObject) {
	// Implementation
});

Using the event object

The first argument that all the listener functions share is the event object, which allows you to manipulate the propagation and default action of the event. Some events are followed by an action that can be, for instance, to turn the page. Therefore, it’s possible to prevent that action by using event.preventDefault(); within the event function. It’s not necessary to return false to prevent the default action.

List of Events

<yambe:breadcrumb>API</yambe:breadcrumb>