Method: range: Difference between revisions

From Turn.js Documentation
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
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
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: <tt>range[0] <= $("#flipbook").turn("page") <= range[1]</tt>
range. That is, the current range always has the following relationship: <tt>range[0] <= $("#flipbook").turn("page") <= range[1]</tt>
{| class="wikitable"
|-
! scope="col"| Parameter
! scope="col"| Type
! scope="col"| Description
! scope="col"| Default Value
|-
| pageNumber
| Number
| A page number within a range
| <pre class="javascript">$("#flipbook").turn("page")</pre>
|}
For example, in order to add new pages dynamically, you could use use the range method:
<pre class="javascript">
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);
}
}
</pre>


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

Revision as of 16:51, 6 July 2012

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
$("#flipbook").turn("page")

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); 
	}
}

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