import React, { useCallback } from "react"; import { useMouseEventsTimeline } from "~/pages/PageEnigma/comps/Timeline/utils/useMouseEventsTimeline"; import { timelineScrollX, currentTime, dndTimelineHeight, overTimeline, scale, timelineHeight, } from "~/pages/PageEnigma/store"; import Queue from "~/pages/PageEnigma/Queue/Queue"; import { QueueNames } from "~/pages/PageEnigma/Queue/QueueNames"; import { toEngineActions } from "~/pages/PageEnigma/Queue/toEngineActions"; interface LowerPanelPropsI { children: React.ReactNode; onStyle?: boolean; } export const LowerPanel = ({ children, onStyle }: LowerPanelPropsI) => { const { onPointerDown } = useMouseEventsTimeline(); const displayHeight = dndTimelineHeight.value > -1 ? dndTimelineHeight.value : timelineHeight.value; const onTimelineClick = useCallback( (event: React.PointerEvent) => { if (event.button === 0) { const newTime = Math.round( (event.clientX + timelineScrollX.value - 92) / 4 / scale.value, ); if (newTime < 0) { return; } currentTime.value = newTime; Queue.publish({ queueName: QueueNames.TO_ENGINE, action: toEngineActions.UPDATE_TIME, data: { currentTime: Math.round(newTime) }, }); } }, [], ); return ( <> {!onStyle && (
)}
{ overTimeline.value = true; }} onPointerLeave={() => (overTimeline.value = false)} onPointerDown={onTimelineClick} > {children}
); };