Main Page: Difference between revisions

From Turn.js Documentation
Jump to navigation Jump to search
No edit summary
 
(115 intermediate revisions by the same user not shown)
Line 1: Line 1:
The first release of turn.js introduced a pretty simple way for adding new pages. In fact, the only thing you had to do was to add as many elements as pages you needed for your book or magazine. Quickly, this scheme brought up a problem in cases where the book contained a large amount of pages.  The solution was to provide a way for creating pages on the fly. Therefore, the 3rd release of turn.js allows you to create pages dynamically.The API is also simple and consistent with the way you are familiar for setting event listeners. This new feature is the foundation in which any kind of e-reader app will be achievable.
Turn.js is a library that will make your content look like a real book or magazine with just HTML content. It uses HTML5 and CSS3 to perform the effects, reason why it works nicely on touch devices such as iOS devices (iPad, iPhone, iPod) and Android devices.  


Turn.js takes all the advantages of having real HTML content over flash content. Besides the feeling of native content (selectable content, no third-party contextual menus), it's possible to add advertisement codes, HTML5 videos, tooltips, images, maps, forms, keep tracking of every page and combine them with hundreds of clever libraries made for the Web.
==Let's take a look at how it works==
1. We create the HTML
<pre class="xml">
<div id="flipbook">
  <div class="hard"> Turn.js </div>
  <div class="hard"></div>
  <div> Page 1 </div>
  <div> Page 2 </div>
  <div> Page 3 </div>
  <div> Page 4 </div>
  <div class="hard"></div>
  <div class="hard"></div>
</div>
</pre>
2. Then the JavaScript part
<pre class="javascript">
<pre class="javascript">
function load() {
$("#flipbook").turn({
if (turn.browser.support()) {
  width: 400,
$('selector').turn({
  height: 300,
elevation: 50,
  autoCenter: true
acceleration: true,
});
gradients: true,
autoCenter: true,
duration: 1000,
pages: 112,
width:960,
height:600
});
}
}
</pre>
</pre>


If our reader is currently in the page 6, the view for that page will be <tt>6,7</tt>. From <tt>6-7</tt>, turn.js wants to keep in memory 4 more pages. Therefore, our DOM and JavaScript cache will have the pages <tt>[4, 5, 6, 7, 8, 9]</tt>. For instance, if our reader is in page 1, the pages to keep in DOM are <tt>[1, 2, 3, 4, 5, 6]</tt>.   
[http://jsfiddle.net/blasten/A9a7E Here's the result on jsFiddle]
 
== Turn.js 4th release==
Turn.js 4th release has over 10 different performance improvements and more than 20 new features.  The improvements were mainly focused on making the effects much more fluent and smoother as well as reducing memory consumption when using the browser's GPU and storing elements in the DOM tree.  It also supports old browsers such as IE8 by adding a new file called turn.html4.js, which has the exact same API (methods, properties) but it deals with the effects in a different way on HTML4-based browsers.
 
==Flipbook==
 
Turn is the built-in jQuery plugin that comes with the turn.js development kit, which allows you to create flipbooks. These are the options, properties, methods, events and CSS classes available in turn.js 4.0.9 release.
 
:{| class="simple"
! scope="col"  width="225" | [[Turn Options|Options]]
! scope="col" width="225" |  [[Turn Properties|Properties]]
! scope="col" width="225" |  [[Turn Methods|Methods]]
! scope="col" width="225" |  [[Turn Events|Events]]
! scope="col" width="225" |  [[Turn CSS|CSS Classes]]
 
|-
| valign="top" |
* [[Option: acceleration|acceleration]]
* [[Option: autoCenter|autoCenter]]
* [[Option: direction|direction]]
* [[Option: display|display]]
* [[Option: duration|duration]]
* [[Option: gradients|gradients]]
* [[Option: height|height]]
* [[Option: elevation|elevation]]
* [[Option: page|page]]
* [[Option: pages|pages]]
* [[Option: turnCorners|turnCorners]]
* [[Option: when|when]]
* [[Option: width|width]]
| valign="top" |
 
* [[Property: animating|animating]]
* [[Property: direction|direction]]
* [[Property: display|display]]
* [[Property: disabled|disabled]]
* [[Property: page|page]]
* [[Property: pages|pages]]
* [[Property: size|size]]
* [[Property: options|options]]
* [[Property: view|view]]
* [[Property: zoom|zoom]]
 
 
| valign="top" |
 
* [[Method: addPage|addPage]]
* [[Method: center|center]]
* [[Method: destroy|destroy]]
* [[Method: direction|direction]]
* [[Method: display|display]]
* [[Method: disable|disable]]
* [[Method: hasPage|hasPage]]
* [[Method: next|next]]
* [[Method: is|is]]
* [[Method: options|options]]
* [[Method: page|page]]
* [[Method: pages|pages]]
* [[Method: peel|peel]]
* [[Method: previous|previous]]
* [[Method: range|range]]
* [[Method: removePage|removePage]]
* [[Method: resize|resize]]
* [[Method: size|size]]
* [[Method: stop|stop]]
* [[Method: version|version]]
* [[Method: zoom|zoom]]
 
| valign="top"  |
 
* [[Event: end|end]]
* [[Event: first|first]]
* [[Event: last|last]]
* [[Event: missing|missing]]
* [[Event: start|start]]
* [[Event: turning|turning]]
* [[Event: turned|turned]]
* [[Event: zooming|zooming]]
 
| valign="top" |
* [[Class: .even|.even]]
* [[Class: .fixed|.fixed]]
* [[Class: .hard|.hard]]
* [[Class: .odd|.odd]]
* [[Class: .own-size|.own-size]]
* [[Class: .page|.page]]
* [[Class: .p|.p[0-9]+]]
* [[Class: .shadow|.shadow]]
* [[Class: .sheet|.sheet]]
 
|}
 
==Zoom Viewport==
 
To implement the new zoom function, a new component is available since turn.js 4.0.2 to define the viewport of the pages when zoomed in. There's an article about [[How to add zoom to turn.js|how to add zoom to turn.js]].
 
:{| class="simple" width="600"
! scope="col" width="225" | [[Zoom Options | Options]]
! scope="col" width="225" | [[Zoom Properties | Properties]]
! scope="col" width="225" |  [[Zoom Methods | Methods]]
! scope="col" width="225" | [[Zoom Events | Events]]
 
|-
| valign="top" |
* [[Option: easeFunction|easeFunction]]
* [[Zoom Option: duration|duration]]
* [[Option: max|max]]
* [[Option: flipbook|flipbook]]
* [[Zoom Option: when|when]]
 
| valign="top" |
 
* [[Property: value|value]]
 
 
| valign="top"  |
 
* [[Method: zoomIn|zoomIn]]
* [[Method: zoomOut|zoomOut]]
 
 
| valign="top"  |
* [[Event: change|change]]
* [[Event: doubleTap|doubleTap]]
* [[Event: resize|resize]]
* [[Event: swipeLeft|swipeLeft]]
* [[Event: swipeRight|swipeRight]]
* [[Event: tap|tap]]
* [[Event: zoomIn|zoomIn]]
* [[Event: zoomOut|zoomOut]]
|}
 
==Scissors==


Consult the [//meta.wikimedia.org/wiki/Help:Contents User's Guide] for information on using the wiki software.
Scissors is literally a scissor that cuts a page in two parts, so that you can have double pages made entirely in HTML5  and split them into two pages.


== Getting started ==
[[Scissor|Read more about Scissor]]
* [//www.mediawiki.org/wiki/Manual:Configuration_settings Configuration settings list]
__NOTOC__
* [//www.mediawiki.org/wiki/Manual:FAQ MediaWiki FAQ]
* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]

Latest revision as of 06:20, 26 November 2012

Turn.js is a library that will make your content look like a real book or magazine with just HTML content. It uses HTML5 and CSS3 to perform the effects, reason why it works nicely on touch devices such as iOS devices (iPad, iPhone, iPod) and Android devices.

Turn.js takes all the advantages of having real HTML content over flash content. Besides the feeling of native content (selectable content, no third-party contextual menus), it's possible to add advertisement codes, HTML5 videos, tooltips, images, maps, forms, keep tracking of every page and combine them with hundreds of clever libraries made for the Web.

Let's take a look at how it works

1. We create the HTML

<div id="flipbook">
  <div class="hard"> Turn.js </div> 
  <div class="hard"></div>
  <div> Page 1 </div>
  <div> Page 2 </div>
  <div> Page 3 </div>
  <div> Page 4 </div>
  <div class="hard"></div>
  <div class="hard"></div>
</div>

2. Then the JavaScript part

$("#flipbook").turn({
  width: 400,
  height: 300,
  autoCenter: true
});

Here's the result on jsFiddle

Turn.js 4th release

Turn.js 4th release has over 10 different performance improvements and more than 20 new features. The improvements were mainly focused on making the effects much more fluent and smoother as well as reducing memory consumption when using the browser's GPU and storing elements in the DOM tree. It also supports old browsers such as IE8 by adding a new file called turn.html4.js, which has the exact same API (methods, properties) but it deals with the effects in a different way on HTML4-based browsers.

Flipbook

Turn is the built-in jQuery plugin that comes with the turn.js development kit, which allows you to create flipbooks. These are the options, properties, methods, events and CSS classes available in turn.js 4.0.9 release.

Options Properties Methods Events CSS Classes


Zoom Viewport

To implement the new zoom function, a new component is available since turn.js 4.0.2 to define the viewport of the pages when zoomed in. There's an article about how to add zoom to turn.js.

Options Properties Methods Events



Scissors

Scissors is literally a scissor that cuts a page in two parts, so that you can have double pages made entirely in HTML5 and split them into two pages.

Read more about Scissor