tonkean-react-calendar-timeline
Advanced tools
Comparing version
@@ -465,3 +465,3 @@ 'use strict'; | ||
var stackingMethod = stackItems ? _calendar.stack : _calendar.nostack; | ||
var stackingMethod = !stackItems ? _calendar.nostack : stackItems === 'force' ? _calendar.forcestack : _calendar.stack; | ||
@@ -654,3 +654,3 @@ var _stackingMethod = stackingMethod(dimensionItems, groupOrders, lineHeight, headerHeight), | ||
stackItems: _propTypes2.default.bool, | ||
stackItems: _propTypes2.default.string, | ||
@@ -778,3 +778,3 @@ traditionalZoom: _propTypes2.default.bool, | ||
stackItems: false, | ||
stackItems: null, | ||
@@ -781,0 +781,0 @@ traditionalZoom: false, |
@@ -18,2 +18,3 @@ 'use strict'; | ||
exports.stack = stack; | ||
exports.forcestack = forcestack; | ||
exports.nostack = nostack; | ||
@@ -280,2 +281,40 @@ | ||
function forcestack(items, groupOrders, lineHeight, force) { | ||
var i, iMax; | ||
var totalHeight = 0; | ||
var groupHeights = []; | ||
var groupTops = []; | ||
var groupedItems = getGroupedItems(items, groupOrders); | ||
if (force) { | ||
// reset top position of all items | ||
for (i = 0, iMax = items.length; i < iMax; i++) { | ||
items[i].dimensions.top = null; | ||
} | ||
} | ||
// stack all the items on top of eachother taking vertical margin into account. | ||
groupedItems.forEach(function (group) { | ||
groupTops.push(totalHeight); | ||
var groupHeight = 0; | ||
var verticalMargin = 0; | ||
for (i = 0, iMax = group.length; i < iMax; i++) { | ||
var item = group[i]; | ||
verticalMargin = lineHeight - item.dimensions.height; | ||
item.dimensions.top = totalHeight + groupHeight + verticalMargin; | ||
groupHeight += lineHeight; | ||
} | ||
groupHeights.push(Math.max(groupHeight + verticalMargin, lineHeight)); | ||
totalHeight += Math.max(groupHeight + verticalMargin, lineHeight); | ||
}); | ||
return { | ||
height: totalHeight, | ||
groupHeights: groupHeights, | ||
groupTops: groupTops | ||
}; | ||
} | ||
function nostack(items, groupOrders, lineHeight, force) { | ||
@@ -282,0 +321,0 @@ var i, iMax; |
{ | ||
"name": "tonkean-react-calendar-timeline", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "react calendar timeline", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -21,2 +21,3 @@ import PropTypes from 'prop-types' | ||
stack, | ||
forcestack, | ||
nostack, | ||
@@ -65,3 +66,3 @@ calculateDimensions, | ||
stackItems: PropTypes.bool, | ||
stackItems: PropTypes.string, | ||
@@ -190,3 +191,3 @@ traditionalZoom: PropTypes.bool, | ||
stackItems: false, | ||
stackItems: null, | ||
@@ -1097,3 +1098,3 @@ traditionalZoom: false, | ||
const stackingMethod = stackItems ? stack : nostack | ||
const stackingMethod = !stackItems ? nostack : (stackItems === 'force' ? forcestack : stack); | ||
@@ -1100,0 +1101,0 @@ const { height, groupHeights, groupTops } = stackingMethod( |
@@ -280,2 +280,40 @@ import moment from 'moment' | ||
export function forcestack(items, groupOrders, lineHeight, force) { | ||
var i, iMax; | ||
var totalHeight = 0; | ||
var groupHeights = []; | ||
var groupTops = []; | ||
var groupedItems = getGroupedItems(items, groupOrders); | ||
if (force) { | ||
// reset top position of all items | ||
for (i = 0, iMax = items.length; i < iMax; i++) { | ||
items[i].dimensions.top = null | ||
} | ||
} | ||
// stack all the items on top of eachother taking vertical margin into account. | ||
groupedItems.forEach(function(group) { | ||
groupTops.push(totalHeight); | ||
var groupHeight = 0; | ||
var verticalMargin = 0; | ||
for (i = 0, iMax = group.length; i < iMax; i++) { | ||
var item = group[i]; | ||
verticalMargin = lineHeight - item.dimensions.height; | ||
item.dimensions.top = totalHeight + groupHeight + verticalMargin; | ||
groupHeight += lineHeight; | ||
} | ||
groupHeights.push(Math.max(groupHeight + verticalMargin, lineHeight)); | ||
totalHeight += Math.max(groupHeight + verticalMargin, lineHeight); | ||
}); | ||
return { | ||
height: totalHeight, | ||
groupHeights, | ||
groupTops | ||
} | ||
} | ||
export function nostack(items, groupOrders, lineHeight, force) { | ||
@@ -282,0 +320,0 @@ var i, iMax |
297192
0.77%6489
1.03%