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

Prevent items from being repeatedly redrawn while off screen #3633

Merged
merged 2 commits into from
Nov 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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