diff --git a/lib/timeline/Range.js b/lib/timeline/Range.js index 0ae6dec0..38ddd317 100644 --- a/lib/timeline/Range.js +++ b/lib/timeline/Range.js @@ -16,7 +16,8 @@ function Range(body, options) { var now = moment().hours(0).minutes(0).seconds(0).milliseconds(0); var start = now.clone().add(-3, 'days').valueOf(); var end = now.clone().add(3, 'days').valueOf(); - + this.millisecondsPerPixelCache = undefined; + if(options === undefined) { this.start = start; this.end = end; @@ -200,6 +201,7 @@ Range.prototype.setRange = function(start, end, options, callback) { var finalStart = start != undefined ? util.convert(start, 'Date').valueOf() : null; var finalEnd = end != undefined ? util.convert(end, 'Date').valueOf() : null; this._cancelAnimation(); + this.millisecondsPerPixelCache = undefined; if (options.animation) { // true or an Object var initStart = this.start; @@ -280,7 +282,10 @@ Range.prototype.setRange = function(start, end, options, callback) { * Get the number of milliseconds per pixel. */ Range.prototype.getMillisecondsPerPixel = function() { - return (this.end - this.start) / this.body.dom.center.clientWidth; + if (this.millisecondsPerPixelCache === undefined) { + this.millisecondsPerPixelCache = (this.end - this.start) / this.body.dom.center.clientWidth; + } + return this.millisecondsPerPixelCache; } /**