Skip to content

Commit

Permalink
ui-manchette-with-spacetimechart: always display arrival operational …
Browse files Browse the repository at this point in the history
…point in manchette

Signed-off-by: Clara Ni <[email protected]>
  • Loading branch information
clarani committed Jan 23, 2025
1 parent 2bda78d commit 9f8ac99
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui-manchette-with-spacetimechart/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ export const filterVisibleElements = <T>({
getWeight,
minSpace,
}: VisibilityFilterOptions<T>): T[] => {
const firstElement = elements.at(0);
const lastElement = elements.at(-1);
if (!firstElement || !lastElement) return elements;

const sortedElements = [...elements].sort((a, b) => (getWeight(b) ?? 0) - (getWeight(a) ?? 0));
const displayedElements: { element: T; position: number }[] = [];
const displayedElements: { element: T; position: number }[] = [
{ element: firstElement, position: getPosition(firstElement) },
{ element: lastElement, position: getPosition(lastElement) },
];

for (const element of sortedElements) {
const position = getPosition(element);
Expand Down

0 comments on commit 9f8ac99

Please sign in to comment.