Browse Source

Update Graph2d.js (#3738)

Changes were made to TimeLine.js that need to be in Graph2d.js also. This change fixes zoom/panning issues in Graph2d.
develop
Lopton 6 years ago
committed by Yotam Berkowitz
parent
commit
a6e4153849
1 changed files with 33 additions and 0 deletions
  1. +33
    -0
      lib/timeline/Graph2d.js

+ 33
- 0
lib/timeline/Graph2d.js View File

@ -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);

Loading…
Cancel
Save