From 8bceb44d39f13654540fba2d94b292d45d300d1d Mon Sep 17 00:00:00 2001 From: Tyler Date: Wed, 8 Nov 2023 17:38:42 -0500 Subject: [PATCH] feat(groups): Add ability to provide a number of pixels for the height of a group --- docs/timeline/index.html | 5 +++-- lib/timeline/component/Group.js | 4 +++- lib/timeline/optionsTimeline.js | 4 ++-- types/index.d.ts | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/timeline/index.html b/docs/timeline/index.html index b777065786..95040ce181 100644 --- a/docs/timeline/index.html +++ b/docs/timeline/index.html @@ -703,13 +703,14 @@

Configuration Options

groupHeightMode - String + String or Number 'auto' Specifies how the height of a group is calculated. Choose from 'auto','fixed', and 'fitItems'.
If it is set to 'auto' the height will be calculated based on a group label and visible items.
If it is set to 'fitItems' the height will be calculated based on the visible items only.
- 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.
+ If it is set to a number, this will be the height of the row in number of pixels. diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js index b658430768..dd12c813cf 100644 --- a/lib/timeline/component/Group.js +++ b/lib/timeline/component/Group.js @@ -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' diff --git a/lib/timeline/optionsTimeline.js b/lib/timeline/optionsTimeline.js index ba59913b7c..4db21e6579 100644 --- a/lib/timeline/optionsTimeline.js +++ b/lib/timeline/optionsTimeline.js @@ -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'}, @@ -238,7 +238,7 @@ let configureOptions = { year: '' } }, - groupHeightMode: ['auto', 'fixed', 'fitItems'], + groupHeightMode: ['auto', 'fixed', 'fitItems', 20], //groupOrder: {string, 'function': 'function'}, groupsDraggable: false, height: '', diff --git a/types/index.d.ts b/types/index.d.ts index 77448d8387..6d9642484c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -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;