mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 15:27:47 -02:30
hide overflow in ExpandingContainer while opening
This commit is contained in:
@@ -4,13 +4,19 @@ import styled from 'styled-components';
|
|||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
transition: all 0.2s ease-out;
|
transition: height 0.2s ease-out;
|
||||||
${props => !props.isExpanded && `overflow: hidden;`}
|
${props => props.hideOverflow && `overflow: hidden;`}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function ExpandingContainer({ isExpanded, children }) {
|
function ExpandingContainer({ isExpanded, children }) {
|
||||||
const [contentHeight, setContentHeight] = useState(0);
|
const [contentHeight, setContentHeight] = useState(0);
|
||||||
|
const [hideOverflow, setHideOverflow] = useState(!isExpanded);
|
||||||
const ref = useRef(null);
|
const ref = useRef(null);
|
||||||
|
useEffect(() => {
|
||||||
|
ref.current.addEventListener('transitionend', () => {
|
||||||
|
setHideOverflow(!isExpanded);
|
||||||
|
});
|
||||||
|
})
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setContentHeight(ref.current.scrollHeight);
|
setContentHeight(ref.current.scrollHeight);
|
||||||
});
|
});
|
||||||
@@ -21,7 +27,7 @@ function ExpandingContainer({ isExpanded, children }) {
|
|||||||
css={`
|
css={`
|
||||||
height: ${height}px;
|
height: ${height}px;
|
||||||
`}
|
`}
|
||||||
isExpanded={isExpanded}
|
hideOverflow={!isExpanded || hideOverflow}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
Reference in New Issue
Block a user