From 727031283c89e410029979659649b392fb8b95c0 Mon Sep 17 00:00:00 2001 From: jos Date: Tue, 21 Oct 2014 15:31:37 +0200 Subject: [PATCH] Background areas are now neatly ignored from stacking --- lib/timeline/Stack.js | 4 ++-- lib/timeline/component/item/BackgroundItem.js | 2 +- lib/timeline/component/item/Item.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/timeline/Stack.js b/lib/timeline/Stack.js index 0e3fb867..e39e10c6 100644 --- a/lib/timeline/Stack.js +++ b/lib/timeline/Stack.js @@ -49,7 +49,7 @@ exports.stack = function(items, margin, force) { // calculate new, non-overlapping positions for (i = 0, iMax = items.length; i < iMax; i++) { var item = items[i]; - if (item.top === null) { + if (item.stack && item.top === null) { // initialize top position item.top = margin.axis; @@ -59,7 +59,7 @@ exports.stack = function(items, margin, force) { var collidingItem = null; for (var j = 0, jj = items.length; j < jj; j++) { var other = items[j]; - if (other.top !== null && other !== item && other.ignoreStacking == false && exports.collision(item, other, margin.item)) { + if (other.top !== null && other !== item && other.stack && exports.collision(item, other, margin.item)) { collidingItem = other; break; } diff --git a/lib/timeline/component/item/BackgroundItem.js b/lib/timeline/component/item/BackgroundItem.js index d77bad44..df26500f 100644 --- a/lib/timeline/component/item/BackgroundItem.js +++ b/lib/timeline/component/item/BackgroundItem.js @@ -34,13 +34,13 @@ function BackgroundItem (data, conversion, options) { Item.call(this, data, conversion, options); - this.ignoreStacking = true; // this is not used when stacking this.emptyContent = false; } BackgroundItem.prototype = new Item (null, null, null); BackgroundItem.prototype.baseClassName = 'item background'; +BackgroundItem.prototype.stack = false; /** * Check whether this item is visible inside given range diff --git a/lib/timeline/component/item/Item.js b/lib/timeline/component/item/Item.js index 2bcf6264..9b004970 100644 --- a/lib/timeline/component/item/Item.js +++ b/lib/timeline/component/item/Item.js @@ -26,10 +26,10 @@ function Item (data, conversion, options) { this.left = null; this.width = null; this.height = null; - - this.ignoreStacking = false; } +Item.prototype.stack = true; + /** * Select current item */