Skip to content

Commit

Permalink
fix: update lastStart on every graph update (#651)
Browse files Browse the repository at this point in the history
Normally dragging a line graph (or calling setRange repeatedly to sync
the range with something external) causes only partial updates (the SVG
is moved as a whole, not modified). However, if at the same time full
updates happen the graph can become moved twice: once because the items
have been moved and the second time due to the SVG offset.

To avoid this problem this commit updates the lastStart reference
position not only when the drag ends, but also on any other full graph
rebuild.
  • Loading branch information
tanriol authored Sep 6, 2020
1 parent 446d900 commit 7e15a8e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/timeline/component/LineGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ function LineGraph(body, options) {
this.setOptions(options);
this.groupsUsingDefaultStyles = [0];
this.body.emitter.on('rangechanged', function () {
me.lastStart = me.body.range.start;
me.svg.style.left = util.option.asSize(-me.props.width);

me.forceGraphUpdate = true;
Expand Down Expand Up @@ -637,6 +636,7 @@ LineGraph.prototype._getSortedGroupIds = function(){
* @private
*/
LineGraph.prototype._updateGraph = function () {
this.lastStart = this.body.range.start;
// reset the svg elements
DOMutil.prepareElements(this.svgElements);
if (this.props.width != 0 && this.itemsData != null) {
Expand Down

0 comments on commit 7e15a8e

Please sign in to comment.