mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
Add map for sections and pages, update queue to handle function without promise
This commit is contained in:
parent
f998e5be0a
commit
5c33f9c52b
14 changed files with 1044 additions and 93 deletions
|
@ -67,6 +67,8 @@ EPUBJS.Continuous.prototype.display = function(what){
|
|||
|
||||
this.q.enqueue(this.check);
|
||||
|
||||
this.hooks.display.trigger(view);
|
||||
|
||||
// view.displayed.then(function(){
|
||||
// this.trigger("displayed", section);
|
||||
// this.displaying = false;
|
||||
|
@ -223,26 +225,6 @@ EPUBJS.Continuous.prototype.each = function(func) {
|
|||
return this.views.forEach(func);
|
||||
};
|
||||
|
||||
EPUBJS.Continuous.prototype.isVisible = function(view, _container){
|
||||
var position = view.position();
|
||||
var container = _container || this.container.getBoundingClientRect();
|
||||
|
||||
if(this.settings.axis === "horizontal" &&
|
||||
(position.right >= container.left - this.settings.offset) &&
|
||||
!(position.left >= container.right + this.settings.offset)) {
|
||||
|
||||
return true;
|
||||
|
||||
} else if(this.settings.axis === "vertical" &&
|
||||
(position.bottom >= container.top - this.settings.offset) &&
|
||||
!(position.top >= container.bottom + this.settings.offset)) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
EPUBJS.Continuous.prototype.check = function(){
|
||||
var checking = new RSVP.defer();
|
||||
|
@ -255,7 +237,7 @@ EPUBJS.Continuous.prototype.check = function(){
|
|||
}
|
||||
|
||||
this.views.forEach(function(view){
|
||||
var visible = this.isVisible(view, container);
|
||||
var visible = this.isVisible(view, this.settings.offset, container);
|
||||
|
||||
if(visible) {
|
||||
|
||||
|
@ -523,3 +505,48 @@ EPUBJS.Continuous.prototype.scrollTo = function(x, y, silent){
|
|||
}
|
||||
|
||||
};
|
||||
/*
|
||||
EPUBJS.Continuous.prototype.current = function(what){
|
||||
var view, top;
|
||||
var container = this.container.getBoundingClientRect();
|
||||
var length = this.views.length - 1;
|
||||
|
||||
if(this.settings.axis === "horizontal") {
|
||||
|
||||
for (var i = length; i >= 0; i--) {
|
||||
view = this.views[i];
|
||||
left = view.position().left;
|
||||
|
||||
if(left < container.right) {
|
||||
|
||||
if(this._current == view) {
|
||||
break;
|
||||
}
|
||||
|
||||
this._current = view;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
for (var i = length; i >= 0; i--) {
|
||||
view = this.views[i];
|
||||
top = view.bounds().top;
|
||||
if(top < container.bottom) {
|
||||
|
||||
if(this._current == view) {
|
||||
break;
|
||||
}
|
||||
|
||||
this._current = view;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this._current;
|
||||
};
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue