Method: range: Difference between revisions

From Turn.js Documentation
Jump to navigation Jump to search
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
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>
The last example will add the pages that are closest to the page 10.
Assuming that display is <tt>double</tt>, those pages are <tt>[8, 9, 10, 11, 12, 13]</tt>.


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

Latest revision as of 01:18, 7 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); 
	}
}

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>