From 4281092ffccb28bc2e5cf3279aac7d9f00a723f3 Mon Sep 17 00:00:00 2001 From: vezwork Date: Fri, 6 May 2022 14:24:20 -0400 Subject: [PATCH] Fix `MarkerDot` non-visible when out of rightDims Co-authored-by: Aria Minaei Co-authored-by: Cole Lawrence --- .../RightOverlay/MarkerDot.tsx | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/MarkerDot.tsx b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/MarkerDot.tsx index 7173a97..6bc9be8 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/MarkerDot.tsx +++ b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/MarkerDot.tsx @@ -40,6 +40,13 @@ const dims = (w: number, h = w) => ` height: ${h}px; ` +const MarkerDotContainer = styled.div` + position: absolute; + // below the sequence ruler "top bar" + top: 18px; + z-index: ${() => zIndexes.marker}; +` + const MarkerVisualDot = styled.div` position: absolute; ${dims(MARKER_SIZE_W_PX, MARKER_SIZE_H_PX)} @@ -113,22 +120,43 @@ const MarkerDot: React.VFC = ({layoutP, markerId}) => { return null } - return + // check marker in viewable bounds + const clippedSpaceWidth = useVal(layoutP.clippedSpace.width) + const clippedSpaceFromUnitSpace = useVal(layoutP.clippedSpace.fromUnitSpace) + const clippedSpaceMarkerX = clippedSpaceFromUnitSpace(marker.position) + + const outsideClipDims = + clippedSpaceMarkerX <= 0 || clippedSpaceMarkerX > clippedSpaceWidth + + // If outside the clip space, we want to hide the marker dot. We + // hide the dot by translating it far away and scaling it to 0. + // This method of hiding does not cause reflow/repaint. + const translateX = outsideClipDims ? -10000 : clippedSpaceMarkerX + const scale = outsideClipDims ? 0 : 1 + + return ( + + + + ) } export default MarkerDot -type IMarkerDotDefinedProps = { +type IMarkerDotVisibleProps = { layoutP: Pointer marker: StudioHistoricStateSequenceEditorMarker } -const MarkerDotDefined: React.VFC = ({ +const MarkerDotVisible: React.VFC = ({ layoutP, marker, }) => { const sheetAddress = useVal(layoutP.sheet.address) - const clippedSpaceFromUnitSpace = useVal(layoutP.clippedSpace.fromUnitSpace) const [markRef, markNode] = useRefAndState(null) @@ -143,17 +171,7 @@ const MarkerDotDefined: React.VFC = ({ }) return ( -
+ <> {contextMenu} = ({ className={isDragging ? 'beingDragged' : ''} /> -
+ ) }