Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify height of a group #1713

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/timeline/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,14 @@ <h2 id="Configuration_Options">Configuration Options</h2>

<tr>
<td>groupHeightMode</td>
<td>String</td>
<td>String or Number</td>
<td>'auto'</td>
<td>
Specifies how the height of a group is calculated. Choose from 'auto','fixed', and 'fitItems'. <br />
If it is set to 'auto' the height will be calculated based on a group label and visible items.<br />
If it is set to 'fitItems' the height will be calculated based on the visible items only.<br />
While if it is set to 'fixed' the group will keep the same height even if there are no visible items in the window.
While if it is set to 'fixed' the group will keep the same height even if there are no visible items in the window.<br />
If it is set to a number, this will be the height of the row in number of pixels.
</td>
</tr>

Expand Down
4 changes: 3 additions & 1 deletion lib/timeline/component/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,9 @@ class Group {

let items;

if (this.heightMode === 'fixed') {
if (typeof this.heightMode === 'number') {
return this.heightMode;
} else if (this.heightMode === 'fixed') {
items = util.toArray(this.items);
} else {
// default or 'auto'
Expand Down
4 changes: 2 additions & 2 deletions lib/timeline/optionsTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ let allOptions = {
__type__: {object}
},
moment: {'function': 'function'},
groupHeightMode: {string},
groupHeightMode: {string, number},
groupOrder: {string, 'function': 'function'},
groupEditable: {
add: { 'boolean': bool, 'undefined': 'undefined'},
Expand Down Expand Up @@ -238,7 +238,7 @@ let configureOptions = {
year: ''
}
},
groupHeightMode: ['auto', 'fixed', 'fitItems'],
groupHeightMode: ['auto', 'fixed', 'fitItems', 20],
//groupOrder: {string, 'function': 'function'},
groupsDraggable: false,
height: '',
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export type TimelineOptionsSnapFunction = (date: Date, scale: string, step: numb
export type TimelineOptionsSnapType = null | TimelineOptionsSnapFunction;
export type TimelineOptionsTemplateFunction = (item?: any, element?: any, data?: any) => string | HTMLElement;
export type TimelineOptionsComparisonFunction = (a: any, b: any) => number;
export type TimelineOptionsGroupHeightModeType = 'auto' | 'fixed' | 'fitItems';
export type TimelineOptionsGroupHeightModeType = 'auto' | 'fixed' | 'fitItems' | number;
export type TimelineOptionsClusterCriteriaFunction = (firstItem: TimelineItem, secondItem: TimelineItem) => boolean;
export type TimelineOptionsCluster = {
titleTemplate?: string;
Expand Down