Skip to content

Commit

Permalink
🚧 Add transition when toggling panel transitions
Browse files Browse the repository at this point in the history
This currently has two problems:

1. It does not allow dropdowns from within the options to render lower
   than the boundaries.
2. It transitions the height from viewport height to 0, however all the
   actual panel option divs are shorter than that. This means there is a
   delay before the transition makes a visible change, and the speed is
   much faster than if it went from panel option div's height to 0.

(2) is more of a nuisance and can be addressed by dynamically setting
the max-height based on the containing div's scrollHeight, however (1)
is the prevailing and blocking problem.
  • Loading branch information
victorlin committed Nov 15, 2023
1 parent 4e2de85 commit 92d66ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/controls/panelSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useSelector } from "react-redux";
import { PanelSectionContainer } from "./styles";
import { PanelOptionsContainer, PanelSectionContainer } from "./styles";
import { Title, Tooltip } from "./annotatedTitle";
import { PanelHeader, PanelId } from "./panelHeader";
import { RootState } from "../../store";
Expand Down Expand Up @@ -42,7 +42,9 @@ export const PanelSection = ({ panel, title, tooltip, options=undefined }: Props
optionsAreVisible={optionsAreVisible}
setOptionsAreVisible={setOptionsAreVisible}
/>
{optionsAreVisible && options}
<PanelOptionsContainer className={`${optionsAreVisible ? "open" : ""}`}>
{options}
</PanelOptionsContainer>
</PanelSectionContainer>
);
};
12 changes: 12 additions & 0 deletions src/components/controls/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ export const PanelSectionContainer = styled.div`
}
`;

export const PanelOptionsContainer = styled.div`
visibility: hidden;
transition: visibility .5s, max-height .5s;
max-height: 0;
overflow: hidden;
&.open {
visibility: visible;
max-height: 100vh;
}
`

export const TitleAndIconContainer = styled.span`
display: inline-flex;
align-items: center;
Expand Down

0 comments on commit 92d66ea

Please sign in to comment.