Method: range

From Turn.js Documentation
Jump to navigation Jump to search

Returns an array of two values where the first element refers to a page number from which next pages should be contained in the DOM tree. The second element refers to the last page number of the range. That is, the current range always has the following relationship: range[0] <= $("#flipbook").turn("page") <= range[1]

Parameter Type Description Default Value
pageNumber Number A page number within a range

For example, in order to add new pages dynamically, you could use use the range method:

var range = $("#flipbook").turn("range", 10);

for (var page = range[0]; page<=range[1]; page++){
	if (!$("#flipbook").turn("hasPage", page)) {
		$("#flipbook").turn("addPage", $("<div />"), page); 

The last example will add the pages that are closest to the page 10.

Assuming that display is double, those pages are [8, 9, 10, 11, 12, 13].

<yambe:breadcrumb>Turn Methods</yambe:breadcrumb>