Make sure we always have a valid container element before calculating the dimensions of the various charts
This commit is contained in:
parent
a64c9a5d7f
commit
404055decc
1 changed files with 9 additions and 0 deletions
|
@ -139,6 +139,7 @@ ImageHistoryTree.prototype.setupOverscroll_ = function() {
|
||||||
ImageHistoryTree.prototype.updateDimensions_ = function() {
|
ImageHistoryTree.prototype.updateDimensions_ = function() {
|
||||||
var container = this.container_;
|
var container = this.container_;
|
||||||
var dimensions = this.calculateDimensions_(container);
|
var dimensions = this.calculateDimensions_(container);
|
||||||
|
if (!dimensions) { return; }
|
||||||
|
|
||||||
var m = dimensions.m;
|
var m = dimensions.m;
|
||||||
var w = dimensions.w;
|
var w = dimensions.w;
|
||||||
|
@ -909,6 +910,10 @@ function FileTreeBase() {
|
||||||
*/
|
*/
|
||||||
FileTreeBase.prototype.calculateDimensions_ = function(container) {
|
FileTreeBase.prototype.calculateDimensions_ = function(container) {
|
||||||
var containerElm = document.getElementById(container);
|
var containerElm = document.getElementById(container);
|
||||||
|
if (!containerElm) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var cw = containerElm ? containerElm.clientWidth : 1200;
|
var cw = containerElm ? containerElm.clientWidth : 1200;
|
||||||
var barHeight = 20;
|
var barHeight = 20;
|
||||||
var ch = (this.getNodesHeight() * barHeight) + 40;
|
var ch = (this.getNodesHeight() * barHeight) + 40;
|
||||||
|
@ -940,6 +945,7 @@ FileTreeBase.prototype.updateDimensions_ = function() {
|
||||||
|
|
||||||
var container = this.container_;
|
var container = this.container_;
|
||||||
var dimensions = this.calculateDimensions_(container);
|
var dimensions = this.calculateDimensions_(container);
|
||||||
|
if (!dimensions) { return; }
|
||||||
|
|
||||||
var w = dimensions.w;
|
var w = dimensions.w;
|
||||||
var h = dimensions.h;
|
var h = dimensions.h;
|
||||||
|
@ -989,6 +995,7 @@ FileTreeBase.prototype.draw = function(container) {
|
||||||
this.container_ = container;
|
this.container_ = container;
|
||||||
|
|
||||||
var dimensions = this.calculateDimensions_(container);
|
var dimensions = this.calculateDimensions_(container);
|
||||||
|
if (!dimensions) { return; }
|
||||||
|
|
||||||
var w = dimensions.w;
|
var w = dimensions.w;
|
||||||
var h = dimensions.h;
|
var h = dimensions.h;
|
||||||
|
@ -1107,6 +1114,8 @@ FileTreeBase.prototype.getVisibleCount_ = function(node) {
|
||||||
*/
|
*/
|
||||||
FileTreeBase.prototype.getContainerHeight_ = function() {
|
FileTreeBase.prototype.getContainerHeight_ = function() {
|
||||||
var dimensions = this.calculateDimensions_(this.container_);
|
var dimensions = this.calculateDimensions_(this.container_);
|
||||||
|
if (!dimensions) { return; }
|
||||||
|
|
||||||
var barHeight = this.barHeight_;
|
var barHeight = this.barHeight_;
|
||||||
var height = (this.getVisibleCount_(this.root_) * (barHeight + 2));
|
var height = (this.getVisibleCount_(this.root_) * (barHeight + 2));
|
||||||
return height + dimensions.m[0] + dimensions.m[2];
|
return height + dimensions.m[0] + dimensions.m[2];
|
||||||
|
|
Reference in a new issue