mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Goto will take you back to first page of chapter
This commit is contained in:
parent
d84203711a
commit
48612637d4
12 changed files with 752 additions and 722 deletions
|
@ -3227,9 +3227,12 @@ EPUBJS.Book.prototype.gotoHref = function(url, defer){
|
|||
deferred.resolve(this.renderer.currentLocationCfi);
|
||||
}.bind(this));
|
||||
}else{
|
||||
//-- Only goto section
|
||||
//-- Goto section
|
||||
if(section) {
|
||||
this.renderer.section(section);
|
||||
} else {
|
||||
// Or jump to the start
|
||||
this.renderer.firstPage();
|
||||
}
|
||||
deferred.resolve(this.renderer.currentLocationCfi);
|
||||
}
|
||||
|
@ -4936,6 +4939,7 @@ EPUBJS.Layout.Fixed.prototype.calculatePages = function(){
|
|||
pageCount : 1
|
||||
};
|
||||
};
|
||||
|
||||
EPUBJS.Pagination = function(pageList) {
|
||||
this.pages = [];
|
||||
this.locations = [];
|
||||
|
@ -6116,6 +6120,11 @@ EPUBJS.Renderer.prototype.lastPage = function(){
|
|||
this.page(this.displayedPages);
|
||||
};
|
||||
|
||||
// Jump to the first page of the chapter
|
||||
EPUBJS.Renderer.prototype.firstPage = function(){
|
||||
this.page(1);
|
||||
};
|
||||
|
||||
//-- Find a section by fragement id
|
||||
EPUBJS.Renderer.prototype.section = function(fragment){
|
||||
var el = this.doc.getElementById(fragment),
|
||||
|
@ -6246,32 +6255,30 @@ EPUBJS.Renderer.prototype.mapPage = function(){
|
|||
var children = Array.prototype.slice.call(node.childNodes);
|
||||
if (node.nodeType == Node.ELEMENT_NODE) {
|
||||
elPos = node.getBoundingClientRect();
|
||||
if(elPos.left + elPos.width > elLimit) {
|
||||
|
||||
// console.log("checking text node of: ", node);
|
||||
if(!elPos || (elPos.width === 0 && elPos.height === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(elPos.left + elPos.width > elLimit) {
|
||||
children.forEach(function(node){
|
||||
if(node.nodeType == Node.TEXT_NODE &&
|
||||
node.textContent.trim().length) {
|
||||
checkText(node);
|
||||
}
|
||||
});
|
||||
// renderer.textSprint(node, checkText);
|
||||
}
|
||||
}
|
||||
|
||||
// if (node.nodeType != Node.TEXT_NODE) {
|
||||
// renderer.handleTextNode(node, map, prevRange, limit, cfi);
|
||||
// }
|
||||
};
|
||||
var checkText = function(node){
|
||||
var ranges = renderer.splitTextNodeIntoWordsRanges(node);
|
||||
ranges.forEach(function(range){
|
||||
var pos = range.getBoundingClientRect();
|
||||
// console.log(pos.left, pos.top, node);
|
||||
|
||||
// if(!pos || (pos.width === 0 && pos.height === 0)) {
|
||||
// return;
|
||||
// }
|
||||
if(!pos || (pos.width === 0 && pos.height === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(pos.left + pos.width < limit) {
|
||||
if(!map[page-1].start){
|
||||
|
@ -6845,6 +6852,7 @@ EPUBJS.Renderer.prototype.replaceWithStored = function(query, attr, func, callba
|
|||
|
||||
//-- Enable binding events to Renderer
|
||||
RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype);
|
||||
|
||||
var EPUBJS = EPUBJS || {};
|
||||
EPUBJS.replace = {};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
4
build/epub.min.js
vendored
4
build/epub.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -3226,9 +3226,12 @@ EPUBJS.Book.prototype.gotoHref = function(url, defer){
|
|||
deferred.resolve(this.renderer.currentLocationCfi);
|
||||
}.bind(this));
|
||||
}else{
|
||||
//-- Only goto section
|
||||
//-- Goto section
|
||||
if(section) {
|
||||
this.renderer.section(section);
|
||||
} else {
|
||||
// Or jump to the start
|
||||
this.renderer.firstPage();
|
||||
}
|
||||
deferred.resolve(this.renderer.currentLocationCfi);
|
||||
}
|
||||
|
@ -4935,6 +4938,7 @@ EPUBJS.Layout.Fixed.prototype.calculatePages = function(){
|
|||
pageCount : 1
|
||||
};
|
||||
};
|
||||
|
||||
EPUBJS.Pagination = function(pageList) {
|
||||
this.pages = [];
|
||||
this.locations = [];
|
||||
|
@ -6115,6 +6119,11 @@ EPUBJS.Renderer.prototype.lastPage = function(){
|
|||
this.page(this.displayedPages);
|
||||
};
|
||||
|
||||
// Jump to the first page of the chapter
|
||||
EPUBJS.Renderer.prototype.firstPage = function(){
|
||||
this.page(1);
|
||||
};
|
||||
|
||||
//-- Find a section by fragement id
|
||||
EPUBJS.Renderer.prototype.section = function(fragment){
|
||||
var el = this.doc.getElementById(fragment),
|
||||
|
@ -6245,32 +6254,30 @@ EPUBJS.Renderer.prototype.mapPage = function(){
|
|||
var children = Array.prototype.slice.call(node.childNodes);
|
||||
if (node.nodeType == Node.ELEMENT_NODE) {
|
||||
elPos = node.getBoundingClientRect();
|
||||
if(elPos.left + elPos.width > elLimit) {
|
||||
|
||||
// console.log("checking text node of: ", node);
|
||||
if(!elPos || (elPos.width === 0 && elPos.height === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(elPos.left + elPos.width > elLimit) {
|
||||
children.forEach(function(node){
|
||||
if(node.nodeType == Node.TEXT_NODE &&
|
||||
node.textContent.trim().length) {
|
||||
checkText(node);
|
||||
}
|
||||
});
|
||||
// renderer.textSprint(node, checkText);
|
||||
}
|
||||
}
|
||||
|
||||
// if (node.nodeType != Node.TEXT_NODE) {
|
||||
// renderer.handleTextNode(node, map, prevRange, limit, cfi);
|
||||
// }
|
||||
};
|
||||
var checkText = function(node){
|
||||
var ranges = renderer.splitTextNodeIntoWordsRanges(node);
|
||||
ranges.forEach(function(range){
|
||||
var pos = range.getBoundingClientRect();
|
||||
// console.log(pos.left, pos.top, node);
|
||||
|
||||
// if(!pos || (pos.width === 0 && pos.height === 0)) {
|
||||
// return;
|
||||
// }
|
||||
if(!pos || (pos.width === 0 && pos.height === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(pos.left + pos.width < limit) {
|
||||
if(!map[page-1].start){
|
||||
|
@ -6844,6 +6851,7 @@ EPUBJS.Renderer.prototype.replaceWithStored = function(query, attr, func, callba
|
|||
|
||||
//-- Enable binding events to Renderer
|
||||
RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype);
|
||||
|
||||
var EPUBJS = EPUBJS || {};
|
||||
EPUBJS.replace = {};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -149,17 +149,17 @@
|
|||
|
||||
// Load in stored pageList from json or local storage
|
||||
///*
|
||||
EPUBJS.core.request("page_list.json").then(function(storedPageList){
|
||||
pageList = storedPageList;
|
||||
console.log(storedPageList)
|
||||
book.loadPagination(pageList);
|
||||
});
|
||||
// EPUBJS.core.request("page_list.json").then(function(storedPageList){
|
||||
// pageList = storedPageList;
|
||||
// console.log(storedPageList)
|
||||
// book.loadPagination(pageList);
|
||||
// });
|
||||
|
||||
|
||||
// Or generate the pageList on the fly
|
||||
// book.ready.all.then(function(){
|
||||
// book.generatePagination();
|
||||
// });
|
||||
book.ready.all.then(function(){
|
||||
book.generatePagination();
|
||||
});
|
||||
|
||||
// Wait for the pageList to be ready and then show slider
|
||||
book.pageListReady.then(function(pageList){
|
||||
|
|
File diff suppressed because one or more lines are too long
30
reader/js/epub.min.js
vendored
30
reader/js/epub.min.js
vendored
|
@ -3227,9 +3227,12 @@ EPUBJS.Book.prototype.gotoHref = function(url, defer){
|
|||
deferred.resolve(this.renderer.currentLocationCfi);
|
||||
}.bind(this));
|
||||
}else{
|
||||
//-- Only goto section
|
||||
//-- Goto section
|
||||
if(section) {
|
||||
this.renderer.section(section);
|
||||
} else {
|
||||
// Or jump to the start
|
||||
this.renderer.firstPage();
|
||||
}
|
||||
deferred.resolve(this.renderer.currentLocationCfi);
|
||||
}
|
||||
|
@ -4936,6 +4939,7 @@ EPUBJS.Layout.Fixed.prototype.calculatePages = function(){
|
|||
pageCount : 1
|
||||
};
|
||||
};
|
||||
|
||||
EPUBJS.Pagination = function(pageList) {
|
||||
this.pages = [];
|
||||
this.locations = [];
|
||||
|
@ -6116,6 +6120,11 @@ EPUBJS.Renderer.prototype.lastPage = function(){
|
|||
this.page(this.displayedPages);
|
||||
};
|
||||
|
||||
// Jump to the first page of the chapter
|
||||
EPUBJS.Renderer.prototype.firstPage = function(){
|
||||
this.page(1);
|
||||
};
|
||||
|
||||
//-- Find a section by fragement id
|
||||
EPUBJS.Renderer.prototype.section = function(fragment){
|
||||
var el = this.doc.getElementById(fragment),
|
||||
|
@ -6246,32 +6255,30 @@ EPUBJS.Renderer.prototype.mapPage = function(){
|
|||
var children = Array.prototype.slice.call(node.childNodes);
|
||||
if (node.nodeType == Node.ELEMENT_NODE) {
|
||||
elPos = node.getBoundingClientRect();
|
||||
if(elPos.left + elPos.width > elLimit) {
|
||||
|
||||
// console.log("checking text node of: ", node);
|
||||
if(!elPos || (elPos.width === 0 && elPos.height === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(elPos.left + elPos.width > elLimit) {
|
||||
children.forEach(function(node){
|
||||
if(node.nodeType == Node.TEXT_NODE &&
|
||||
node.textContent.trim().length) {
|
||||
checkText(node);
|
||||
}
|
||||
});
|
||||
// renderer.textSprint(node, checkText);
|
||||
}
|
||||
}
|
||||
|
||||
// if (node.nodeType != Node.TEXT_NODE) {
|
||||
// renderer.handleTextNode(node, map, prevRange, limit, cfi);
|
||||
// }
|
||||
};
|
||||
var checkText = function(node){
|
||||
var ranges = renderer.splitTextNodeIntoWordsRanges(node);
|
||||
ranges.forEach(function(range){
|
||||
var pos = range.getBoundingClientRect();
|
||||
// console.log(pos.left, pos.top, node);
|
||||
|
||||
// if(!pos || (pos.width === 0 && pos.height === 0)) {
|
||||
// return;
|
||||
// }
|
||||
if(!pos || (pos.width === 0 && pos.height === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(pos.left + pos.width < limit) {
|
||||
if(!map[page-1].start){
|
||||
|
@ -6845,6 +6852,7 @@ EPUBJS.Renderer.prototype.replaceWithStored = function(query, attr, func, callba
|
|||
|
||||
//-- Enable binding events to Renderer
|
||||
RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype);
|
||||
|
||||
var EPUBJS = EPUBJS || {};
|
||||
EPUBJS.replace = {};
|
||||
|
||||
|
|
|
@ -977,9 +977,12 @@ EPUBJS.Book.prototype.gotoHref = function(url, defer){
|
|||
deferred.resolve(this.renderer.currentLocationCfi);
|
||||
}.bind(this));
|
||||
}else{
|
||||
//-- Only goto section
|
||||
//-- Goto section
|
||||
if(section) {
|
||||
this.renderer.section(section);
|
||||
} else {
|
||||
// Or jump to the start
|
||||
this.renderer.firstPage();
|
||||
}
|
||||
deferred.resolve(this.renderer.currentLocationCfi);
|
||||
}
|
||||
|
|
|
@ -410,6 +410,11 @@ EPUBJS.Renderer.prototype.lastPage = function(){
|
|||
this.page(this.displayedPages);
|
||||
};
|
||||
|
||||
// Jump to the first page of the chapter
|
||||
EPUBJS.Renderer.prototype.firstPage = function(){
|
||||
this.page(1);
|
||||
};
|
||||
|
||||
//-- Find a section by fragement id
|
||||
EPUBJS.Renderer.prototype.section = function(fragment){
|
||||
var el = this.doc.getElementById(fragment),
|
||||
|
@ -540,32 +545,30 @@ EPUBJS.Renderer.prototype.mapPage = function(){
|
|||
var children = Array.prototype.slice.call(node.childNodes);
|
||||
if (node.nodeType == Node.ELEMENT_NODE) {
|
||||
elPos = node.getBoundingClientRect();
|
||||
if(elPos.left + elPos.width > elLimit) {
|
||||
|
||||
// console.log("checking text node of: ", node);
|
||||
if(!elPos || (elPos.width === 0 && elPos.height === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(elPos.left + elPos.width > elLimit) {
|
||||
children.forEach(function(node){
|
||||
if(node.nodeType == Node.TEXT_NODE &&
|
||||
node.textContent.trim().length) {
|
||||
checkText(node);
|
||||
}
|
||||
});
|
||||
// renderer.textSprint(node, checkText);
|
||||
}
|
||||
}
|
||||
|
||||
// if (node.nodeType != Node.TEXT_NODE) {
|
||||
// renderer.handleTextNode(node, map, prevRange, limit, cfi);
|
||||
// }
|
||||
};
|
||||
var checkText = function(node){
|
||||
var ranges = renderer.splitTextNodeIntoWordsRanges(node);
|
||||
ranges.forEach(function(range){
|
||||
var pos = range.getBoundingClientRect();
|
||||
// console.log(pos.left, pos.top, node);
|
||||
|
||||
// if(!pos || (pos.width === 0 && pos.height === 0)) {
|
||||
// return;
|
||||
// }
|
||||
if(!pos || (pos.width === 0 && pos.height === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(pos.left + pos.width < limit) {
|
||||
if(!map[page-1].start){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue