diff --git a/src/timeline/component/ItemSet.js b/src/timeline/component/ItemSet.js index 7be528c1..e87b392d 100644 --- a/src/timeline/component/ItemSet.js +++ b/src/timeline/component/ItemSet.js @@ -219,8 +219,9 @@ ItemSet.prototype.repaint = function repaint() { // check whether zoomed (in that case we need to re-stack everything) var visibleInterval = this.range.end - this.range.start; - var zoomed = (this.visibleInterval != visibleInterval); - this.visibleInterval = visibleInterval; + var zoomed = (visibleInterval != this.lastVisibleInterval) || (this.width != this.lastWidth); + this.lastVisibleInterval = visibleInterval; + this.lastWidth = this.width; /* TODO: implement+fix smarter way to update visible items // find the first visible item diff --git a/src/timeline/component/RootPanel.js b/src/timeline/component/RootPanel.js index d8f61901..b87455f1 100644 --- a/src/timeline/component/RootPanel.js +++ b/src/timeline/component/RootPanel.js @@ -14,6 +14,8 @@ function RootPanel(container, options) { this.defaultOptions = { autoResize: true }; + + this._initWatch(); } RootPanel.prototype = new Panel(); @@ -28,26 +30,20 @@ RootPanel.prototype = new Panel(); * {String | Number | function} [height] * {Boolean | function} [autoResize] */ -RootPanel.prototype.setOptions = function (options) { +RootPanel.prototype.setOptions = function setOptions(options) { if (options) { util.extend(this.options, options); this.repaint(); - var autoResize = this.getOption('autoResize'); - if (autoResize) { - this._watch(); - } - else { - this._unwatch(); - } + this._initWatch(); } }; /** * Repaint the root panel */ -RootPanel.prototype.repaint = function () { +RootPanel.prototype.repaint = function repaint() { // create frame if (!this.frame) { if (!this.container) throw new Error('Cannot repaint root panel: no container attached'); @@ -98,17 +94,31 @@ RootPanel.prototype.repaint = function () { } }; +/** + * Initialize watching when option autoResize is true + * @private + */ +RootPanel.prototype._initWatch = function _initWatch() { + var autoResize = this.getOption('autoResize'); + if (autoResize) { + this._watch(); + } + else { + this._unwatch(); + } +}; + /** * Watch for changes in the size of the frame. On resize, the Panel will * automatically redraw itself. * @private */ -RootPanel.prototype._watch = function () { +RootPanel.prototype._watch = function _watch() { var me = this; this._unwatch(); - var checkSize = function () { + var checkSize = function checkSize() { var autoResize = me.getOption('autoResize'); if (!autoResize) { // stop watching when the option autoResize is changed to false @@ -138,7 +148,7 @@ RootPanel.prototype._watch = function () { * Stop watching for a resize of the frame. * @private */ -RootPanel.prototype._unwatch = function () { +RootPanel.prototype._unwatch = function _unwatch() { if (this.watchTimer) { clearInterval(this.watchTimer); this.watchTimer = undefined;