From cf8c299d11ba7f6baf9b67c23ae788426e6dd472 Mon Sep 17 00:00:00 2001 From: jos Date: Thu, 30 Apr 2015 10:38:48 +0200 Subject: [PATCH] Removed the option `padding` for Timeline, is now redundant (can be done purely with css now) --- docs/timeline.html | 13 ------------ lib/timeline/component/ItemSet.js | 8 ++------ lib/timeline/component/item/RangeItem.js | 7 +++---- test/timeline.html | 25 ++++++++++++++++++++---- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/docs/timeline.html b/docs/timeline.html index 9c4a3089..6b92cac1 100644 --- a/docs/timeline.html +++ b/docs/timeline.html @@ -706,19 +706,6 @@ var options = { Orientation of the timeline items: 'top' or 'bottom' (default). Determines whether items are aligned to the top or bottom of the Timeline. - - padding - Number - 5 - The padding of items, needed to correctly calculate the size - of item ranges. Must correspond with the css of items, for example when setting options.padding=10, corresponding css is: -
-.vis.timeline .item {
-  padding: 10px;
-}
- - - selectable Boolean diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index 9be1e4ab..3c6de0f4 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -66,8 +66,7 @@ function ItemSet(body, options) { vertical: 10 }, axis: 20 - }, - padding: 5 + } }; // options is shared by this ItemSet and all its items @@ -243,9 +242,6 @@ ItemSet.prototype._create = function(){ * and vertical direction. Default is 10. * {Number} margin * Set margin for both axis and items in pixels. - * {Number} padding - * Padding of the contents of an item in pixels. - * Must correspond with the items css. Default is 5. * {Boolean} selectable * If true (default), items can be selected. * {Boolean} editable @@ -276,7 +272,7 @@ ItemSet.prototype._create = function(){ ItemSet.prototype.setOptions = function(options) { if (options) { // copy all options that we know - var fields = ['type', 'align', 'order', 'padding', 'stack', 'selectable', 'groupOrder', 'dataAttributes', 'template','hide', 'snap']; + var fields = ['type', 'align', 'order', 'stack', 'selectable', 'groupOrder', 'dataAttributes', 'template','hide', 'snap']; util.selectiveExtend(fields, this.options, options); if ('orientation' in options) { diff --git a/lib/timeline/component/item/RangeItem.js b/lib/timeline/component/item/RangeItem.js index 53bec65c..fcc65e8b 100644 --- a/lib/timeline/component/item/RangeItem.js +++ b/lib/timeline/component/item/RangeItem.js @@ -188,8 +188,7 @@ RangeItem.prototype.repositionX = function(limitSize) { else { this.left = start; this.width = boxWidth; - contentWidth = Math.min(end - start - 2 * this.options.padding, this.props.content.width); - // TODO: remove the need for options.padding. it's terrible. + contentWidth = Math.min(end - start, this.props.content.width); } this.dom.box.style.left = this.left + 'px'; @@ -201,11 +200,11 @@ RangeItem.prototype.repositionX = function(limitSize) { break; case 'right': - this.dom.content.style.left = Math.max((boxWidth - contentWidth - 2 * this.options.padding), 0) + 'px'; + this.dom.content.style.left = Math.max((boxWidth - contentWidth), 0) + 'px'; break; case 'center': - this.dom.content.style.left = Math.max((boxWidth - contentWidth - 2 * this.options.padding) / 2, 0) + 'px'; + this.dom.content.style.left = Math.max((boxWidth - contentWidth) / 2, 0) + 'px'; break; default: // 'auto' diff --git a/test/timeline.html b/test/timeline.html index 3e4dd1ca..e6fb7e13 100644 --- a/test/timeline.html +++ b/test/timeline.html @@ -44,14 +44,23 @@ -
+

-

+

+

+ + +

-
+

-

+