電子書,turn.js 官方文檔,翻譯成中文 。2019.01.08翻譯

// 基本用法

$("#flipbook").turn({
acceleration:true,

})

// 選件=============================================================================================

// 加速--------------------------------------------
//設置硬件加速模式,對於觸摸設備,此值必須爲true。
option : acceleration
type : Boolean
Default Value : true

//自動居中--------------------------------------------
option : autoCenter
type : Boolean
Default Value : false

usage :
+++++++++++++++++++++
#flipbook{
-webkit-transition:margin-left 0.2s ease-in-out;
-moz-transition:margin-left 0.2s ease-in-out;
-o-transition:margin-left 0.2s ease-in-out;
-ms-transition:margin-left 0.2s ease-in-out;
transition:margin-left 0.2s ease-in-out;
}
+++++++++++++++++++++

//方向--------------------------------------------
指定從左到右(DIR = ltr,默認值)或從右到左(DIR = rtl)的活動簿的方向性。
option : direction
type : String
Default Value : ltr

usage :
+++++++++++++++++++++

js:
$(“ #flipbook”).turn({direction:“ rtl” });

html:
< div id = “ flipbook” dir = “ rtl” >
<!-Pages->
</ div >

css:
#flipbook {
方向:rtl ;
}

+++++++++++++++++++++

//顯示--------------------------------------------
設置顯示模式。使用單頁 single 顯示每個視圖僅一頁,或使用雙頁 double 顯示兩個頁面。
option : display
type : String
Default Value : double

//過渡時間--------------------------------------------
設置過渡的持續時間(以毫秒爲單位)。如果設置爲0(零),則翻頁時將不會進行過渡。
Option: duration
type : Number
Default Value : 600

//漸變色--------------------------------------------
在過渡期間顯示漸變和陰影。
Option: gradients
type : Boolean
Default Value : true

//高度--------------------------------------------
設置活動頁的高度
option : height
type : Number
Default Value : $(“flipbook”).height()

//高程--------------------------------------------
設置過度期間頁面的高程
option : elevation
type : Number
Default Value : 0

//頁--------------------------------------------
設置’初始化’頁面數量
option : page
type : Number
Default Value : 1

//頁面--------------------------------------------
設置任意數量的頁面。如果頁面數大於#flipbook中的元素數,則必須使用addPage方法動態添加這些頁面。
option : pages
type : Number
Default Value : $("#flipbook").children().length

//翻頁角--------------------------------------------
option : turnCorners
type : String
Default Value : bl,br

格式
{left-corner},{right-corner}
可能的值
bl,br或tl,tr 或bl,tr

var way = 1 ;
setInterval(function () {
if(way == 1){
KaTeX parse error: Expected 'EOF', got '#' at position 4: (“ #̲flipbook”).turn…(“ #flipbook”).turn(“ page”)== $(“ #flipbook“).turn(” pages“)){
方式= 2 ;
$(” #flipbook“).turn(” options“,{turnCorners:” tl,tr“ });
}
} else {
$(”

“上一個”);if($(“ #flipbook”).turn(“ page”)== 1){
   方式= 1 ;
   $(“ #flipbook”).turn(“ options”,{turnCorners:“ bl,br” });
}

}
},1000);

//何時--------------------------------------------
option : when
type : Object
Default Value : Empty object

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

//寬度--------------------------------------------
option : width
type : Number
Default Value : $("#flipbook").width();

//性質=============================================================================================

=============================================================================================

//動畫--------------------------------------------
設置頁面動畫時,即摺疊頁面可見時,返回true。

Example:

function isAnimating() {
if ($("#flipbook").turn(“animating”)) {
alert(‘Animating a page!’);
}
}

//方向--------------------------------------------
返回活動簿的當前方向。即從左到右(DIR = ltr,默認值)或從右到左(DIR = rtl)。
Property: direction
例:
$(“ #flipbook”).turn(“ direction”);

//顯示--------------------------------------------
獲取當前顯示。它可以是single或double。
Property: display

例:

alert(“當前顯示爲:” + $(“ #flipbook”).turn(“ display”));

//禁用--------------------------------------------
如果禁用了活頁簿,則返回true。
Property: disabled

//頁--------------------------------------------
獲取當前頁。
例:

alert(“當前頁面爲:” + $(“ #flipbook”).turn(“ page”));

//頁面--------------------------------------------
獲取活動簿中的頁數。
例:
alert(“ #flipbook具有” + $(“ #flipbook”).turn(“ pages”)+ “ pages”);

//大小--------------------------------------------
獲取活動簿的大小。這將是一個具有兩個鍵,width和height的對象。
Property: size
例:

var size = $(“ #flipbook”).turn(“ size”);
alert(“ Width:” + size.width + “,Height:” + size.height);

//選項--------------------------------------------
獲取創建活動簿時使用的選項。
Property: options

Example:

var duration = $("#flipbook").turn(“options”).duration;

alert("The duration of the transition is "+duration);

//視圖--------------------------------------------
獲取當前視圖。

例:

var view = $(“ #flipbook”).turn(“ view”). join (“和”);
alert(“當前視圖:” + view);

//縮放--------------------------------------------
獲取活動簿的乘法因子。默認值爲1,這意味着活動簿的大小與size方法指定的大小相同。
Property: zoom

Example:

var zoom = $("#flipbook").turn(“zoom”);
alert("當前縮放: "+zoom);

// 方法=============================================================================================

=============================================================================================

//添加頁面--------------------------------------------
Method: addPage

++++++++++++++++++++
參數 類型 描述 默認值
element jQuery element Pointer to the DOM element of the page $("

")
pageNumber Number Page Number $("#flipbook").turn(“pages”)+1
++++++++++++++++++++

要插入第10頁,您可以執行以下操作:
element = $(“

”)。html(“ Loading …”);
$(“ #flipbook”).turn(“ addPage”,element,10);

要麼
element = $(“

”,{ “ class”:“ p10” })。html(“ Loading …”);
$(“ #flipbook”).turn(“ addPage”,元素);

請注意,CSS類p10 也指示要插入的頁碼。

//中心--------------------------------------------
根據可見的頁面數量來使活動簿居中。center方法更改#flipbook的CSS margin-left屬性,以使活動簿居中。因此,如果需要更改活動簿的左邊距,建議將活動簿插入容器中以使用其邊距屬性。
如果活動簿的autoCenter選項設置爲true,則可能不必使用此方法。
Method: center
例:

$(“ #flipbook”).turn(“ center”);

居中時添加CSS過渡:

#flipbook{
transition:margin-left 1s;
-webkit-transition:margin-left 1s;
-moz-transition:margin-left 1s;
-o-transition:margin-left 1s;
-ms-transition:margin-left 1s;
transition:margin-left 1s;
}

//銷燬--------------------------------------------
銷燬活頁簿。也就是說,它將刪除DOM樹和內存以及事件偵聽器中的所有頁面。
Method: destroy
例:

$(“ #flipbook”).turn(“ destroy”);

您還可以刪除容器#flipbook,例如:

$(“ #flipbook”).turn(“ destroy”). remove ();
注意:銷燬活動簿會自動破壞縮放視口(如果已定義)。

//方向--------------------------------------------
設置活動簿的方向性。即從左到右(DIR = ltr,默認值)或從右到左(DIR = rtl)。
Method: direction

++++++++++++++++++++
參數 類型 描述 默認值
direction String left-to-right (ltr) or right-to-left (rtl) You must specify this parameter
++++++++++++++++++++

Example:

$("#flipbook").turn(“direction”, “rtl”);

//顯示--------------------------------------------
設置顯示。有兩種顯示模式:單視圖每個視圖只顯示一頁,而雙視圖則每個視圖只顯示兩頁。
Method: display

++++++++++++++++++++
參數 類型 描述 默認值
displayMode String Display value You must specify this parameter
++++++++++++++++++++

例:

$(“ #flipbook”).turn(“ display”,“ single”);
注意:使用單一顯示將規則overflow:hidden隱藏到活動簿中。

//禁用--------------------------------------------
禁用並啓用效果。如果禁用,則用戶將無法更改當前頁面。
Method: disable

++++++++++++++++++++
參數 類型 描述 默認值
disable Boolean Enables or disables the effect You must specify this parameter
++++++++++++++++++++

Example:

$("#flipbook").turn(“disable”, true);

//hasPage--------------------------------------------
如果活動簿有頁面,則返回true。
Method: hasPage

++++++++++++++++++++
參數 類型 描述 默認值
pageNumber Number 頁碼 您必須指定此參數
++++++++++++++++++++

Example:

function checkPage(page) {
if ($("#flipbook").turn(“hasPage”, page)) {
alert(“Page “+page+” is already in the flipbook”);
}
}

//檢查是否頁面1處於翻書

checkPage(1);

// 下一個--------------------------------------------
將視圖轉到下一個視圖。
Method: next

例:

$(“ #flipbook”).turn(“ next”);

例:

$(“ #flipbook”).turn(“ next”);

// is--------------------------------------------

檢測選擇器是否具有turn.js實例。
Method: is

例:

if(!$(“ #flipbook”).turn(“is”)){
//創建一個新的翻書
$(“ #flipbook”).turn();
}

//制定頁面--------------------------------------------
將頁面轉到參數中指定的頁面。
Method: page

++++++++++++++++++++
參數 類型 描述 默認值
page Number Page number You must specify this parameter
++++++++++++++++++++

Example:

// Turn to the page 10
$("#flipbook").turn(“page”, 10);

//頁面--------------------------------------------
設置頁數。如果頁數少於當前頁數,則其他頁將從活動簿中刪除。
將頁面轉到參數中指定的頁面。
Method: pages

++++++++++++++++++++
參數 類型 描述 默認值
pages Number Amount of pages You must specify this parameter
++++++++++++++++++++
Example:

$("#flipbook").turn(“pages”, 5);
Another example:

$("#flipbook").turn(“hasPage”, 10); // It’s true.
$("#flipbook").turn(“pages”, 5); // Sets 5 pages
$("#flipbook").turn(“hasPage”, 10); // Returns false

//剝離--------------------------------------------
在指定的角落顯示一個剝離頁面。
Method: peel

++++++++++++++++++++
參數 類型 描述 默認值
corner String Corner You must specify this parameter
animate Boolean true Animation
++++++++++++++++++++

Example:

// Shows a peeling page at the bottom right corner
$("#flipbook").turn(“peel”, “br”);

//上一個 --------------------------------------------
將視圖轉到上一個視圖。
Method: previous
例:

$(“ #flipbook”).turn(“previous”);

您還可以從當前視圖向後退兩個視圖:

$(“ #flipbook”).turn(“previous”).turn(“previous”);

//範圍 --------------------------------------------
Method: range
返回一個由兩個值組成的數組,其中第一個元素引用一個頁碼,DOM樹中應包含該頁碼。
第二個元素引用範圍的最後一頁號。也就是說,當前範圍始終具有以下關係:range [0] <= $(“#flipbook”)。turn(“ page”)<= range [1]

++++++++++++++++++++
參數 類型 描述 默認值
pageNumber Number 範圍內的頁碼 $(“ #flipbook”).turn(“page”)
++++++++++++++++++++

例如,爲了動態添加新頁面,可以使用range方法:hod:

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

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

"), page);
}
}
最後一個示例將添加最接近頁面10的頁面。

假設顯示爲兩倍,則這些頁面爲[8,9,10,11,12,13]。

//刪除頁面 --------------------------------------------
Method: removePage

++++++++++++++++++++
參數 類型 描述 默認值
pageNumber Number The page to remove You must specify the parameter
++++++++++++++++++++

Example:

// Delete the page 10
$("#flipbook").turn(“removePage”, 10);

//調整大小 --------------------------------------------
重新計算所有頁面的大小和位置
Method: resize

例:
$(“ #flipbook”).turn(“resize”);

//尺寸 --------------------------------------------
設置活動簿的大小。
Method: size

++++++++++++++++++++
參數 類型 描述 默認值
width Number The page to remove You must specify the parameter
height Number The page to remove You must specify the parameter
++++++++++++++++++++

Example:

//調整翻書爲1000x600
$("#flipbook").turn(“size”, 1000, 600);

//停止 --------------------------------------------
停止當前過渡。
Method: stop

//將頁面切換到10,而不進行過渡
$(“ #flipbook”).turn(“ page”,10).turn(‘stop’);

//版本 --------------------------------------------
獲取當前發行版本。
$(“ #flipbook”).turn(“ version”);
//輸出爲4.0.6

//縮放 --------------------------------------------
增加或減小活動簿的大小。縮放方法根據縮放比例更改活動簿的寬度和高度。
如果因子爲1,則翻書將採用size方法指定的原始大小。
Method: zoom

++++++++++++++++++++
參數 類型 描述 默認值
factor Number Factor of multiplication You must specify the parameter
++++++++++++++++++++

Example:

////將活動簿 縮小一半。
$("#flipbook").turn(“zoom”, 0.5);

// 事件=============================================================================================

=============================================================================================

//結束 --------------------------------------------
頁面轉換停止時觸發此事件。
Event: end

++++++++++++++++++++
參數 類型 描述
event Object Event Object
pageObject Object The page object
pageTurned Boolean True if the page was turned
++++++++++++++++++++

Example:

$("#flipbook").bind(“end”, function(event, pageObject, turned){
alert(“turn.end:” +pageObject.page);
});

事件順序
開始 Start
轉彎 Turning
轉身 Turned
結束 End

//第一 --------------------------------------------
當前頁面爲1時觸發此事件。
Event: first

++++++++++++++++++++
參數 類型 描述
event Object Event Object
++++++++++++++++++++

Example:

$("#flipbook").bind(“first”, function(event) {
alert(“您在動畫書的開頭”);
});

//最後 --------------------------------------------
當前頁是活動簿的最後一頁時,將觸發此事件。
Event: last
++++++++++++++++++++
參數 類型 描述
event Object Event Object
++++++++++++++++++++

Example:

$("#flipbook").bind(“last”, function(event) {
alert(“You are at the end of the flipbook”);
});

//失蹤 --------------------------------------------
當前範圍中需要某些頁面時,將觸發此事件。
Event: missing
++++++++++++++++++++
參數 類型 描述
event Object Event Object
++++++++++++++++++++

例:

$(“ #flipbook”). bind(“ missing”,function (event,pages) {
for(var i = 0 ; i <pages.length; i ++){
this.turnaddPage(this).turn(“ addPage”,(“

”)),第[i])頁;
}
}});

//開始 --------------------------------------------
Event: start
++++++++++++++++++++
參數 類型 描述
event Object 事件對象
pageObject Object 頁面對象
corner Number 角型
++++++++++++++++++++

默認動作
顯示摺疊的頁面

例如,如果要防止在使用tl和tr角時開始播放動畫,則可以使用start事件並阻止其默認操作:

$("#flipbook").bind(“start”, function(event, pageObject, corner) {
if (corner==“tl” || corner==“tr”) {
event.preventDefault();
}
});

//轉彎 --------------------------------------------
翻頁之前觸發此事件。
Event: turning
++++++++++++++++++++
參數 類型 描述
event Object 事件對象
page Number 頁碼
view Array The new view
++++++++++++++++++++

默認動作
翻頁

例如:

$(“ #flipbook”). bind(“ turning”,function (event,page,view) {
alert(“將頁面轉到:” + page);
});

您可以防止轉到第1頁。

$(“ #flipbook”). bind(“ turning”,function (event,page,view) {
if(page == 1){
event.preventDefault();
}
});

//已轉彎 --------------------------------------------
翻頁後觸發此事件。
Event: turned
++++++++++++++++++++
參數 類型 描述
event Object 事件對象
page Number The new page number
view Array The new view
++++++++++++++++++++

For example:

$("#flipbook").bind(“turned”, function(event, page, view) {
alert("Page: "+page);
});

//縮放 --------------------------------------------
更改縮放比例時觸發此事件。
Event: zooming

++++++++++++++++++++
參數 類型 描述
event Object The event object
newZoomValue Number 新的縮放係數
currentZoomValue Number 當前縮放係數
++++++++++++++++++++

默認動作
改變變焦
For example:

$("#flipbook").bind(“zooming”, function(event, newZoomValue, currentZoomValue) {
alert("New zoom: "+currentZoomValue);
});

// css類=============================================================================================

=============================================================================================

樣式直接看官方文檔–

http://www.turnjs.com/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章