UNPKG

@atlaskit/navigation-system

Version:

Page layout and navigation components for Atlassian apps.

20 lines (19 loc) • 757 B
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; import { useEffect, useState } from 'react'; /** * Keep the delayed content fade attached after the shorter panel slide finishes. */ export function usePanelContentEnter(state) { var _useState = useState(state === 'entering'), _useState2 = _slicedToArray(_useState, 2), hasEntered = _useState2[0], setHasEntered = _useState2[1]; useEffect(function () { if (state !== 'visible') { setHasEntered(state === 'entering'); } }, [state]); // Exit/hidden removes the animation so reopening starts a fresh fade. A panel // initially mounted as visible should not gain an entrance animation. return state === 'entering' || state === 'visible' && hasEntered; }