1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

Added render functions to rendition and views

This commit is contained in:
fchasen 2016-05-08 11:23:27 -04:00
parent 948c356597
commit ddb127cac5
17 changed files with 1402 additions and 679 deletions

View file

@ -69,16 +69,14 @@ Contents.prototype.textHeight = function() {
return height;
};
Contents.prototype.scrollWidth = function(min) {
var prev;
var width = this.document.body.scrollWidth;
Contents.prototype.scrollWidth = function() {
var width = this.documentElement.scrollWidth;
return width;
};
Contents.prototype.scrollHeight = function(min) {
var prev;
var height = this.document.body.scrollHeight;
Contents.prototype.scrollHeight = function() {
var height = this.documentElement.scrollHeight;
return height;
};
@ -149,6 +147,10 @@ Contents.prototype.viewport = function() {
// // stub
// };
Contents.prototype.expand = function() {
//TODO: this should just report resize
};
Contents.prototype.listeners = function() {
this.imageLoadListeners();
@ -197,6 +199,28 @@ Contents.prototype.mediaQueryListeners = function() {
}
};
Contents.prototype.observe = function(target) {
var renderer = this;
// create an observer instance
var observer = new MutationObserver(function(mutations) {
if(renderer._expanding) {
renderer.expand();
}
// mutations.forEach(function(mutation) {
// console.log(mutation);
// });
});
// configuration of the observer:
var config = { attributes: true, childList: true, characterData: true, subtree: true };
// pass in the target node, as well as the observer options
observer.observe(target, config);
return observer;
};
Contents.prototype.imageLoadListeners = function(target) {
var images = this.contentDocument.querySelectorAll("img");
var img;
@ -403,6 +427,16 @@ Contents.prototype.map = function(layout){
return map.section();
};
Contents.prototype.destroy = function() {
// Stop observing
if(this.observer) {
this.observer.disconnect();
}
this.removeListeners();
};
RSVP.EventTarget.mixin(Contents.prototype);
module.exports = Contents;