This repository has been archived by the owner on Jul 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial trial * Add onInitialDrawComplete * Add docs * Add to eventListeners examples * Keeping things DRY * Remove callback insertion * Remove call * Fix initial real first draw complete and fix comments from review * remove all <code><code>
- Loading branch information
Showing
5 changed files
with
59 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,13 +58,14 @@ function Timeline (container, items, groups, options) { | |
width: null, | ||
height: null, | ||
maxHeight: null, | ||
minHeight: null | ||
minHeight: null, | ||
}; | ||
this.options = util.deepExtend({}, this.defaultOptions); | ||
|
||
// Create the DOM, props, and emitter | ||
this._create(container); | ||
if (!options || (options && typeof options.rtl == "undefined")) { | ||
this.dom.root.style.visibility = 'hidden'; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yotamberk
Author
Contributor
|
||
var directionFromDom, domNode = this.dom.root; | ||
while (!directionFromDom && domNode) { | ||
directionFromDom = window.getComputedStyle(domNode, null).direction; | ||
|
@@ -76,6 +77,7 @@ function Timeline (container, items, groups, options) { | |
} | ||
|
||
this.options.rollingMode = options && options.rollingMode; | ||
this.options.onInitialDrawComplete = options && options.onInitialDrawComplete; | ||
|
||
// all components listed here will be repainted automatically | ||
this.components = []; | ||
|
@@ -160,11 +162,11 @@ function Timeline (container, items, groups, options) { | |
} | ||
|
||
//Single time autoscale/fit | ||
this.fitDone = false; | ||
this.initialFitDone = false; | ||
this.on('changed', function (){ | ||
if (this.itemsData == null || this.options.rollingMode) return; | ||
if (!me.fitDone) { | ||
me.fitDone = true; | ||
if (!me.initialFitDone) { | ||
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(); | ||
|
@@ -173,11 +175,20 @@ function Timeline (container, items, groups, options) { | |
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 { | ||
} else { | ||
me.fit({animation: false}); | ||
} | ||
} | ||
|
||
if (!me.initialDrawDone && me.initialRangeChangeDone) { | ||
me.initialDrawDone = true; | ||
me.dom.root.style.visibility = 'visible'; | ||
if (me.options.onInitialDrawComplete) { | ||
setTimeout(() => { | ||
return me.options.onInitialDrawComplete(); | ||
}, 0) | ||
} | ||
} | ||
}); | ||
|
||
// apply options | ||
|
@@ -472,21 +483,22 @@ Timeline.prototype.focus = function(id, options) { | |
* provided to specify duration and easing function. | ||
* Default duration is 500 ms, and default easing | ||
* function is 'easeInOutQuad'. | ||
* @param {function} [callback] | ||
*/ | ||
Timeline.prototype.fit = function (options) { | ||
Timeline.prototype.fit = function (options, callback) { | ||
var animation = (options && options.animation !== undefined) ? options.animation : true; | ||
var range; | ||
|
||
var dataset = this.itemsData && this.itemsData.getDataSet(); | ||
if (dataset.length === 1 && dataset.get()[0].end === undefined) { | ||
// a single item -> don't fit, just show a range around the item from -4 to +3 days | ||
range = this.getDataRange(); | ||
this.moveTo(range.min.valueOf(), {animation}); | ||
this.moveTo(range.min.valueOf(), {animation}, callback); | ||
} | ||
else { | ||
// exactly fit the items (plus a small margin) | ||
range = this.getItemRange(); | ||
this.range.setRange(range.min, range.max, { animation: animation }); | ||
this.range.setRange(range.min, range.max, { animation: animation }, callback); | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Is this the cause of #4227? Looks like the intent was to hide the element, do some work, and then unhide it.