namespace-ee / react-calendar-timeline

A modern and responsive react timeline component.
MIT License
1.91k stars 613 forks source link

Add order enforcement in stack process #854

Open trasfract opened 2 years ago

trasfract commented 2 years ago

includes creation of group parameter shouldStackEnforceOrder

Issue Number

In some cases, it is important to enforce the order of items in the same group because they are not of the same type. In the images below, I have added a few items which are meant to be stacked, but the first two red items are related to the first blue item, the next two red items to the next blue item, and the last red item to the last blue item.

With the current code, what we get does not enforce this order (and there is no way to enforce it) image

This PR makes sure that an item cannot be above an item which is in horizontal collision. The resulting screenshot is the following: image

Overview of PR

This PR creates a new group parameter "shouldStackEnforceOrder". Clearly, this parameter depends upon isStacked. If isStacked is undefined or false, this new parameter has no effect. If shouldStackEnforceOrder is defined and true for a group, it uses a slightly modified collision method which ensures order is enforced, as shown on the screenshots above.