Skip to content

Commit

Permalink
Only trim after destroy, no trim timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
fchasen committed May 29, 2015
1 parent 812be32 commit 42efc34
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
21 changes: 11 additions & 10 deletions dist/epub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4577,9 +4577,9 @@ EPUBJS.View.prototype.resized = function(e) {

EPUBJS.View.prototype.display = function(_request) {

if(this.rendering){
return this.displayed;
}
// if(this.rendering){
// return this.displayed;
// }

this.rendering = true;
this.displaying = new RSVP.defer();
Expand Down Expand Up @@ -5597,7 +5597,6 @@ EPUBJS.Continuous.prototype.append = function(view){
this.views.push(view);
this.container.appendChild(view.element);


// view.on("shown", this.afterDisplayed.bind(this));
view.onShown = this.afterDisplayed.bind(this);

Expand Down Expand Up @@ -5712,31 +5711,33 @@ EPUBJS.Continuous.prototype.check = function(){
var visible = this.isVisible(view, this.settings.offset, container);

if(visible) {

if(!view.shown && !view.rendering) {
// console.log("render",view.section.index)
promises.push(this.render(view));
}

} else {

if(view.shown) {
// console.log("destroy", view.section.index)
view.destroy();
this.q.enqueue(this.trim);
}

}

}.bind(this));

clearTimeout(this.trimTimeout);
this.trimTimeout = setTimeout(function(){
this.q.enqueue(this.trim);
}.bind(this), 250);
// clearTimeout(this.trimTimeout);
// this.trimTimeout = setTimeout(function(){
// this.q.enqueue(this.trim);
// }.bind(this), 250);

if(promises.length){

return RSVP.all(promises)
.then(function(posts) {

// Check to see if anything new is on screen after rendering
this.q.enqueue(this.check);

Expand Down
4 changes: 2 additions & 2 deletions dist/epub.min.js

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions lib/epubjs/continuous.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ EPUBJS.Continuous.prototype.append = function(view){
this.views.push(view);
this.container.appendChild(view.element);


// view.on("shown", this.afterDisplayed.bind(this));
view.onShown = this.afterDisplayed.bind(this);

Expand Down Expand Up @@ -241,31 +240,33 @@ EPUBJS.Continuous.prototype.check = function(){
var visible = this.isVisible(view, this.settings.offset, container);

if(visible) {

if(!view.shown && !view.rendering) {
// console.log("render",view.section.index)
promises.push(this.render(view));
}

} else {

if(view.shown) {
// console.log("destroy", view.section.index)
view.destroy();
this.q.enqueue(this.trim);
}

}

}.bind(this));

clearTimeout(this.trimTimeout);
this.trimTimeout = setTimeout(function(){
this.q.enqueue(this.trim);
}.bind(this), 250);
// clearTimeout(this.trimTimeout);
// this.trimTimeout = setTimeout(function(){
// this.q.enqueue(this.trim);
// }.bind(this), 250);

if(promises.length){

return RSVP.all(promises)
.then(function(posts) {

// Check to see if anything new is on screen after rendering
this.q.enqueue(this.check);

Expand Down
6 changes: 3 additions & 3 deletions lib/epubjs/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ EPUBJS.View.prototype.resized = function(e) {

EPUBJS.View.prototype.display = function(_request) {

if(this.rendering){
return this.displayed;
}
// if(this.rendering){
// return this.displayed;
// }

this.rendering = true;
this.displaying = new RSVP.defer();
Expand Down

0 comments on commit 42efc34

Please sign in to comment.