Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Commit e54bb16

Browse files
grahamjyotamberk
authored andcommitted
Timeline: Allow overriding align per item (#3107)
Currently `align` is only available as a global timeline configuration option. This change allows overriding alignment on a per-item basis.
1 parent 22edb38 commit e54bb16

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/timeline/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ <h3 id="items">Items</h3>
261261
<a href="#Styles">Styles</a>.
262262
</td>
263263
</tr>
264+
<tr>
265+
<td>align</td>
266+
<td>String</td>
267+
<td>no</td>
268+
<td>This field is optional. If set this overrides the global <code>align</code> configuration option for this item.
269+
</td>
270+
</tr>
264271
<tr>
265272
<td>content</td>
266273
<td>String</td>

lib/timeline/component/item/RangeItem.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ RangeItem.prototype.repositionX = function(limitSize) {
171171
var parentWidth = this.parent.width;
172172
var start = this.conversion.toScreen(this.data.start);
173173
var end = this.conversion.toScreen(this.data.end);
174+
var align = this.data.align === undefined ? this.options.align : this.data.align;
174175
var contentStartPosition;
175176
var contentWidth;
176177

@@ -217,7 +218,7 @@ RangeItem.prototype.repositionX = function(limitSize) {
217218
}
218219
this.dom.box.style.width = boxWidth + 'px';
219220

220-
switch (this.options.align) {
221+
switch (align) {
221222
case 'left':
222223
if (this.options.rtl) {
223224
this.dom.content.style.right = '0';

0 commit comments

Comments
 (0)