Skip to content

Commit edbb246

Browse files
feat(project): screen animations (#614)
* feat: add screen animations * chore: update snapshots * fix: animation on mount not stable * chore: remove key from media screen routing
1 parent 003e3e5 commit edbb246

File tree

7 files changed

+197
-169
lines changed

7 files changed

+197
-169
lines changed

packages/ui-react/src/components/Animation/Animation.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ type Props = {
1515

1616
export type Status = 'opening' | 'open' | 'closing' | 'closed';
1717

18+
const triggerReflow = (element: HTMLElement | null) => element?.scrollTop;
19+
1820
const Animation: React.FC<Props> = ({
1921
className,
2022
createStyle,
@@ -26,6 +28,7 @@ const Animation: React.FC<Props> = ({
2628
keepMounted = false,
2729
children,
2830
}) => {
31+
const nodeRef = useRef<HTMLDivElement>(null);
2932
const [status, setStatus] = useState<Status>('closed');
3033
const [hasOpenedBefore, setHasOpenedBefore] = useState<boolean>(false);
3134

@@ -35,6 +38,9 @@ const Animation: React.FC<Props> = ({
3538
// use event callbacks to ignore reactive dependencies
3639
const openEvent = useEventCallback(() => {
3740
setHasOpenedBefore(true);
41+
// trigger a reflow to ensure the transition is respected after mount
42+
triggerReflow(nodeRef.current);
43+
3844
timeout.current = window.setTimeout(() => setStatus('opening'), delay);
3945
timeout2.current = window.setTimeout(() => {
4046
setStatus('open');
@@ -70,7 +76,7 @@ const Animation: React.FC<Props> = ({
7076
}
7177

7278
return (
73-
<div style={createStyle(status)} className={className}>
79+
<div style={createStyle(status)} className={className} ref={nodeRef}>
7480
{children}
7581
</div>
7682
);

packages/ui-react/src/components/Header/Header.module.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
// Make header static
2828
//
2929
&.static {
30-
position: static;
30+
position: relative;
31+
z-index: 1;
3132
width: 100%;
3233
}
3334
}

packages/ui-react/src/containers/ShelfList/ShelfList.tsx

+17-14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import usePlaylists from '@jwp/ott-hooks-react/src/usePlaylists';
1616
import Shelf from '../../components/Shelf/Shelf';
1717
import InfiniteScrollLoader from '../../components/InfiniteScrollLoader/InfiniteScrollLoader';
1818
import ErrorPage from '../../components/ErrorPage/ErrorPage';
19+
import Fade from '../../components/Animation/Fade/Fade';
1920

2021
import styles from './ShelfList.module.scss';
2122

@@ -76,20 +77,22 @@ const ShelfList = ({ rows }: Props) => {
7677
data-testid={testId(`shelf-${featured ? 'featured' : type === 'playlist' ? slugify(title || playlist?.title) : type}`)}
7778
aria-label={title || playlist?.title}
7879
>
79-
<Shelf
80-
loading={isPlaceholderData}
81-
error={error}
82-
type={type}
83-
playlist={playlist}
84-
watchHistory={type === PersonalShelf.ContinueWatching ? watchHistoryDictionary : undefined}
85-
title={title || playlist?.title}
86-
featured={featured}
87-
accessModel={accessModel}
88-
isLoggedIn={!!user}
89-
hasSubscription={!!subscription}
90-
posterAspect={posterAspect}
91-
visibleTilesDelta={visibleTilesDelta}
92-
/>
80+
<Fade duration={250} delay={index * 33} open>
81+
<Shelf
82+
loading={isPlaceholderData}
83+
error={error}
84+
type={type}
85+
playlist={playlist}
86+
watchHistory={type === PersonalShelf.ContinueWatching ? watchHistoryDictionary : undefined}
87+
title={title || playlist?.title}
88+
featured={featured}
89+
accessModel={accessModel}
90+
isLoggedIn={!!user}
91+
hasSubscription={!!subscription}
92+
posterAspect={posterAspect}
93+
visibleTilesDelta={visibleTilesDelta}
94+
/>
95+
</Fade>
9396
</section>
9497
);
9598
})}

0 commit comments

Comments
 (0)