Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Update Graph2d.js (almende#3738)
Browse files Browse the repository at this point in the history
Changes were made to TimeLine.js that need to be in Graph2d.js also. This change fixes zoom/panning issues in Graph2d.
  • Loading branch information
Matt-PMCT authored and mojoaxel committed Jun 9, 2019
1 parent 906704a commit 4f4b4c1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/timeline/Graph2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,40 @@ function Graph2d (container, items, groups, options) {
this.dom.root.oncontextmenu = function (event) {
me.emit('contextmenu', me.getEventProperties(event))
};

//Single time autoscale/fit
this.initialFitDone = false;
this.on('changed', function (){
if (me.itemsData == null) return;
if (!me.initialFitDone && !me.options.rollingMode) {
me.initialFitDone = true;
if (me.options.start != undefined || me.options.end != undefined) {
if (me.options.start == undefined || me.options.end == undefined) {
var range = me.getItemRange();
}

var start = me.options.start != undefined ? me.options.start : range.min;
var end = me.options.end != undefined ? me.options.end : range.max;
me.setWindow(start, end, {animation: false});
} else {
me.fit({animation: false});
}
}

if (!me.initialDrawDone && (me.initialRangeChangeDone || (!me.options.start && !me.options.end)
|| me.options.rollingMode)) {
me.initialDrawDone = true;
me.itemSet.initialDrawDone = true;
me.dom.root.style.visibility = 'visible';
me.dom.loadingScreen.parentNode.removeChild(me.dom.loadingScreen);
if (me.options.onInitialDrawComplete) {
setTimeout(() => {
return me.options.onInitialDrawComplete();
}, 0)
}
}
});

// apply options
if (options) {
this.setOptions(options);
Expand Down

0 comments on commit 4f4b4c1

Please sign in to comment.