diff --git a/HISTORY.md b/HISTORY.md index 107647df..a61baed3 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,6 +8,11 @@ http://visjs.org - Fixed #1692: Error when y-axis values are equal. +### Timeline + +- Fixed #1695: Item line and dot not correctly reckoning with the line width + when using left or right align. + ## 2016-02-23, version 4.15.0 diff --git a/lib/timeline/component/item/BoxItem.js b/lib/timeline/component/item/BoxItem.js index a129e0be..8c58ca42 100644 --- a/lib/timeline/component/item/BoxItem.js +++ b/lib/timeline/component/item/BoxItem.js @@ -168,28 +168,33 @@ BoxItem.prototype.hide = function() { BoxItem.prototype.repositionX = function() { var start = this.conversion.toScreen(this.data.start); var align = this.options.align; - var left; // calculate left position of the box if (align == 'right') { this.left = start - this.width; + + // reposition box, line, and dot + this.dom.box.style.left = this.left + 'px'; + this.dom.line.style.left = (start - this.props.line.width) + 'px'; + this.dom.dot.style.left = (start - this.props.line.width / 2 - this.props.dot.width / 2) + 'px'; } else if (align == 'left') { this.left = start; + + // reposition box, line, and dot + this.dom.box.style.left = this.left + 'px'; + this.dom.line.style.left = start + 'px'; + this.dom.dot.style.left = (start + this.props.line.width / 2 - this.props.dot.width / 2) + 'px'; } else { // default or 'center' this.left = start - this.width / 2; - } - // reposition box - this.dom.box.style.left = this.left + 'px'; - - // reposition line - this.dom.line.style.left = (start - this.props.line.width / 2) + 'px'; - - // reposition dot - this.dom.dot.style.left = (start - this.props.dot.width / 2) + 'px'; + // reposition box, line, and dot + this.dom.box.style.left = this.left + 'px'; + this.dom.line.style.left = (start - this.props.line.width / 2) + 'px'; + this.dom.dot.style.left = (start - this.props.dot.width / 2) + 'px'; + } }; /**