From 9768fe96a0a3a1a253865ffdfe676e915c459f49 Mon Sep 17 00:00:00 2001 From: Oleksandra Okhotnykova Date: Wed, 11 Sep 2024 13:18:55 +0200 Subject: [PATCH] OV-198: * `getElementEnd` helper --- .../studio/components/timeline/rows/scenes-row.tsx | 3 +-- .../studio/components/timeline/rows/scripts-row.tsx | 3 +-- frontend/src/bundles/studio/helpers/get-element-end.ts | 9 +-------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/frontend/src/bundles/studio/components/timeline/rows/scenes-row.tsx b/frontend/src/bundles/studio/components/timeline/rows/scenes-row.tsx index 75fd76e5d..df1b31749 100644 --- a/frontend/src/bundles/studio/components/timeline/rows/scenes-row.tsx +++ b/frontend/src/bundles/studio/components/timeline/rows/scenes-row.tsx @@ -22,8 +22,7 @@ const ScenesRow: React.FC = () => { const buttonEnd = getElementEnd( scenesEnd, - buttonWidthInPixels, - pixelsToValue, + pixelsToValue(buttonWidthInPixels), ); return ( diff --git a/frontend/src/bundles/studio/components/timeline/rows/scripts-row.tsx b/frontend/src/bundles/studio/components/timeline/rows/scripts-row.tsx index 540438344..98b0e21c0 100644 --- a/frontend/src/bundles/studio/components/timeline/rows/scripts-row.tsx +++ b/frontend/src/bundles/studio/components/timeline/rows/scripts-row.tsx @@ -21,8 +21,7 @@ const ScriptsRow: React.FC = () => { const buttonEnd = getElementEnd( scriptsEnd, - buttonWidthInPixels, - pixelsToValue, + pixelsToValue(buttonWidthInPixels), ); return ( diff --git a/frontend/src/bundles/studio/helpers/get-element-end.ts b/frontend/src/bundles/studio/helpers/get-element-end.ts index 470a04e8d..a1c4e392c 100644 --- a/frontend/src/bundles/studio/helpers/get-element-end.ts +++ b/frontend/src/bundles/studio/helpers/get-element-end.ts @@ -1,11 +1,4 @@ -import { type PixelsToValue } from 'dnd-timeline'; - -const getElementEnd = ( - itemsEnd: number, - widthInPixels: number, - pixelsToValue: PixelsToValue, -): number => { - const elementWidth = pixelsToValue(widthInPixels); +const getElementEnd = (itemsEnd: number, elementWidth: number): number => { return itemsEnd + (Number.isFinite(elementWidth) ? elementWidth : 0); };