Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Commit

Permalink
Prevent items from being repeatedly redrawn while off screen (#3633)
Browse files Browse the repository at this point in the history
* Prevent items from being repeatedly redrawn while off screen

Fixes #3249 again, because my previous PR got overwritten

* Add JSDocs for #3633
  • Loading branch information
YoshiWalsh authored and yotamberk committed Nov 4, 2017
1 parent fb6872d commit 658324f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
8 changes: 5 additions & 3 deletions lib/timeline/component/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, ran
var redrawQueueLength = 0;

util.forEach(this.items, function (item, key) {
if (!item.displayed) {
if (!item.displayed && (item.isVisible(range) || !item.dom)) {
var returnQueue = true;
redrawQueue[key] = item.redraw(returnQueue);
redrawQueue[key] = item.show(returnQueue);
redrawQueueLength = redrawQueue[key].length;
me.visibleItems.push(item);
}
Expand All @@ -301,7 +301,9 @@ Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, ran
}

util.forEach(this.items, function (item) {
item.repositionX(limitSize);
if(item.displayed) {
item.repositionX(limitSize);
}
});

if (this.doInnerStack && this.itemSet.options.stackSubgroups) {
Expand Down
8 changes: 5 additions & 3 deletions lib/timeline/component/item/BoxItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,14 @@ BoxItem.prototype.redraw = function(returnQueue) {
};

/**
* Show the item in the DOM (when not already displayed). The items DOM will
* Show the item in the DOM (when not already visible). The items DOM will
* be created when needed.
* @param {boolean} [returnQueue=false] whether to return a queue of functions to execute instead of just executing them
* @return {boolean} the redraw queue if returnQueue=true
*/
BoxItem.prototype.show = function() {
BoxItem.prototype.show = function(returnQueue) {
if (!this.displayed) {
this.redraw();
return this.redraw(returnQueue);
}
};

Expand Down
6 changes: 4 additions & 2 deletions lib/timeline/component/item/PointItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,12 @@ PointItem.prototype.redraw = function(returnQueue) {
/**
* Show the item in the DOM (when not already visible). The items DOM will
* be created when needed.
* @param {boolean} [returnQueue=false] whether to return a queue of functions to execute instead of just executing them
* @return {boolean} the redraw queue if returnQueue=true
*/
PointItem.prototype.show = function() {
PointItem.prototype.show = function(returnQueue) {
if (!this.displayed) {
this.redraw();
return this.redraw(returnQueue);
}
};

Expand Down
6 changes: 4 additions & 2 deletions lib/timeline/component/item/RangeItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ RangeItem.prototype.redraw = function(returnQueue) {
/**
* Show the item in the DOM (when not already visible). The items DOM will
* be created when needed.
* @param {boolean} [returnQueue=false] whether to return a queue of functions to execute instead of just executing them
* @return {boolean} the redraw queue if returnQueue=true
*/
RangeItem.prototype.show = function() {
RangeItem.prototype.show = function(returnQueue) {
if (!this.displayed) {
this.redraw();
return this.redraw(returnQueue);
}
};

Expand Down

0 comments on commit 658324f

Please sign in to comment.