Browse Source

Fixed #1695: Item line and dot not correctly reckoning with the line width when using left or right align

codeClimate
jos 8 years ago
parent
commit
23814fc167
2 changed files with 20 additions and 10 deletions
  1. +5
    -0
      HISTORY.md
  2. +15
    -10
      lib/timeline/component/item/BoxItem.js

+ 5
- 0
HISTORY.md View File

@ -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

+ 15
- 10
lib/timeline/component/item/BoxItem.js View File

@ -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';
}
};
/**

Loading…
Cancel
Save