ISSUE-058 - New opening/closing transition props feature added. Last name wiping added.

Now we can define separate opening and closing transition settings as well as common (both ways) transition props.
This is all pretty cool.
Timing for open/close animations and transitions are looking better and more mature.
This commit is contained in:
Kyle Geib committed 2022-03-07 11:50:05 -05:00
1 parent a38af0dec4
commit 9f4e564a74
5 files changed
+162 -80

No files matched your search

@@ -35,6 +35,7 @@ import {
RowLeftHalfPosFlagChangeContainer,
AnimatedRowLeftHalfOutline,
DriverNameContainer,
DriverNameWipe,
} from "./styles";
import useMeasure from "react-use-measure";
@@ -42,6 +43,7 @@ const WIPE_DELAY: Milliseconds = 3500;
const WIPE_DURATION: Milliseconds = 400;
const TRAVEL_DURATION: Milliseconds = 750;
const FULL_WIDTH_DURATION: Milliseconds = 750;
const FULL_WIDTH_CLOSE_DELAY: Milliseconds = 333;
interface TimingTowerRowProps {
car: Car;
@@ -172,7 +174,8 @@ export function TimingTowerRow({
BGTimingTowerDisplayMode.FullLeft,
) ? 5 : 0
}
transitionProps={[{
open={displayMode === BGTimingTowerDisplayMode.FullLeft}
transitionOpeningProps={[{
property: "width",
duration: FULL_WIDTH_DURATION * DDM,
}, {
@@ -182,7 +185,19 @@ export function TimingTowerRow({
property: "border-bottom-right-radius",
duration: TRAVEL_DURATION * DDM,
}]}
wide={displayMode === BGTimingTowerDisplayMode.FullLeft}
transitionClosingProps={[{
property: "width",
duration: FULL_WIDTH_DURATION * DDM,
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
}, {
property: "border-top-right-radius",
duration: TRAVEL_DURATION * DDM,
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
}, {
property: "border-bottom-right-radius",
duration: TRAVEL_DURATION * DDM,
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
}]}
ref={leftHalfRef}
>
<RowLeftHalfLayout>
@@ -220,34 +235,47 @@ export function TimingTowerRow({
</RowLeftHalfPosFlagChangeContainer>
</RowLeftHalfPosFlagContainer>
)}
<DriverNameContainer
transitionProps={[{
property: "opacity",
duration: (FULL_WIDTH_DURATION - 333) * DDM,
delay: 333,
}]}
>
<DriverName visible={displayMode !== BGTimingTowerDisplayMode.FullLeft}>
<DriverNameContainer>
<DriverName
open={displayMode !== BGTimingTowerDisplayMode.FullLeft}
transitionOpeningProps={[{
property: "opacity",
duration: 333 * DDM,
delay: (FULL_WIDTH_DURATION - 333) * DDM,
}]}
transitionClosingProps={[{
property: "opacity",
duration: 333 * DDM,
delay: 0 * DDM,
}]}
>
{car.driver.initials}
</DriverName>
<WipeTransition
visible={displayMode === BGTimingTowerDisplayMode.FullLeft}
angle={89}
duration={(FULL_WIDTH_DURATION + 333) * DDM}
startingCorner={"topLeft"}
manualDimensions={{
height: timingTowerTheme.rowHeightPx,
width: timingTowerTheme.rowLeftHalfWidthPx
+ timingTowerTheme.rowRightHalfWidthPx
- timingTowerTheme.teamGemSize
- timingTowerTheme.posFlagSize
- timingTowerTheme.nameLeftMargin,
}}
<DriverNameWipe
open={displayMode === BGTimingTowerDisplayMode.FullLeft}
transitionOpeningProps={[{
property: "width",
duration: FULL_WIDTH_DURATION * 2 * DDM,
delay: 0 * DDM,
}, {
property: "opacity",
duration: 333 * DDM,
delay: 0 * DDM,
}]}
transitionClosingProps={[{
property: "width",
duration: FULL_WIDTH_DURATION * DDM,
delay: 0 * DDM,
}, {
property: "opacity",
duration: 333 * DDM,
delay: (FULL_WIDTH_DURATION - 333) * DDM,
}]}
>
<DriverName visible={true}>
<DriverName open>
{car.driver.lastName}
</DriverName>
</WipeTransition>
</DriverNameWipe>
</DriverNameContainer>
</RowLeftHalfLayout>
<RowLeftHalfGemContainer>
@@ -292,25 +320,36 @@ export function TimingTowerRow({
BGTimingTowerSplitsMode.Interval,
) ? 5 : 0
}
collapsed={displayMode !== BGTimingTowerDisplayMode.LeftAndRight}
open={displayMode === BGTimingTowerDisplayMode.LeftAndRight}
transitionProps={[{
property: "width",
duration: FULL_WIDTH_DURATION * DDM,
}, {
property: "border-top-right-radius",
duration: TRAVEL_DURATION * DDM,
}, {
property: "border-bottom-right-radius",
duration: TRAVEL_DURATION * DDM,
}]}
transitionClosingProps={[{
property: "width",
duration: FULL_WIDTH_DURATION * DDM,
}]}
transitionOpeningProps={[{
property: "width",
duration: FULL_WIDTH_DURATION * DDM,
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
}]}
hugRight={hugRight}
>
<RowRightHalfLayout>
<TimeDiff
xScale={xScale}
yScale={yScale}
visible={displayMode === BGTimingTowerDisplayMode.LeftAndRight}
transitionProps={[{
open={displayMode === BGTimingTowerDisplayMode.LeftAndRight}
transitionOpeningProps={[{
property: "opacity",
duration: FULL_WIDTH_DURATION * DDM,
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
}]}
transitionClosingProps={[{
property: "opacity",
duration: FULL_WIDTH_DURATION * DDM,
}]}
@@ -1,20 +1,17 @@
import styled, { css } from "styled-components";
import { animated } from "@react-spring/web";
import { Fraction, Px, TransitionArgs } from "../../../../types/style";
import {
Fraction,
Px,
DirectionalTransitionProps,
} from "../../../../types/style";
import { Milliseconds } from "../../../../types/util";
import { commonTransition } from "../../../../utils/styling";
import { commonDirectionalTransition } from "../../../../utils/styling";
import fastestLapIcon from "../../../../public/images/icons/fastest-lap.svg";
type OpenProps = {
open: boolean,
};
type TransitionProps = {
transitionProps: TransitionArgs[],
};
type RowsContainerProps = {
carsToDisplay: number,
retiredCarsPresent: boolean,
@@ -67,33 +64,31 @@ const Rounded = styled.div<RoundedProp>`
border-bottom-right-radius: ${({ roundedCornerBottom = 0 }) => roundedCornerBottom}px;
`;
type RowLeftHalfProps = TransitionProps & {
wide: boolean,
};
export const RowLeftHalf = styled(Rounded)<RowLeftHalfProps>`
export const RowLeftHalf = styled(Rounded)<DirectionalTransitionProps>`
position: absolute;
left: 0;
top: 0;
z-index: 1;
overflow-x: clip;
width: ${({ theme: { design: { timingTower } }, wide }) =>
(wide ? timingTower.rowRightHalfWidthPx : 0) + timingTower.rowLeftHalfWidthPx}px;
width: ${({ theme: { design: { timingTower } }, open }) =>
(open ? timingTower.rowRightHalfWidthPx : 0) + timingTower.rowLeftHalfWidthPx}px;
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
background-color: #000000e5;
${({ transitionProps }) => commonTransition(transitionProps)}
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
`;
RowLeftHalf.displayName = "RowLeftHalf";
type AnimatedRowLeftHalfOutlineProps = OpenProps & TransitionProps & {
type AnimatedRowLeftHalfOutlineProps = DirectionalTransitionProps & {
startThickness: Px,
endThickness: Px,
startColor: string,
endColor: string,
};
export const AnimatedRowLeftHalfOutline = animated(styled(Rounded) <AnimatedRowLeftHalfOutlineProps>`
export const AnimatedRowLeftHalfOutline = animated(styled(Rounded)<AnimatedRowLeftHalfOutlineProps>`
position: absolute;
top: 0;
left: 0;
@@ -106,7 +101,8 @@ export const AnimatedRowLeftHalfOutline = animated(styled(Rounded) <AnimatedRowL
: `${startThickness}px solid ${startColor}`};
outline-offset: ${({ startThickness }) => -startThickness}px;
${({ transitionProps }) => commonTransition(transitionProps)}
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
`);
AnimatedRowLeftHalfOutline.displayName = "AnimatedRowLeftHalfOutline";
@@ -118,7 +114,6 @@ export const RowLeftHalfLayout = styled.div`
display: flex;
padding-left: 3px;
/* align-items: center; */
justify-content: flex-start;
`;
RowLeftHalfLayout.displayName = "RowLeftHalfLayout";
@@ -158,27 +153,29 @@ export const RowLeftHalfGemContainer = styled.div`
`;
RowLeftHalfGemContainer.displayName = "RowLeftHalfGemContainer";
type RowRightHalfProps = TransitionProps & {
collapsed: boolean,
type RowRightHalfProps = DirectionalTransitionProps & {
hugRight: boolean,
};
export const RowRightHalf = styled(Rounded)<RowRightHalfProps>`
position: absolute;
${({ hugRight }) => hugRight
? css`right: 0;` : css`
left: ${p => p.theme.design.timingTower.rowLeftHalfWidthPx}px;
`}
? css`
right: 0;
` : css`
left: ${p => p.theme.design.timingTower.rowLeftHalfWidthPx}px;
`}
top: 0;
width: ${({ theme: { design: { timingTower } }, collapsed }) =>
collapsed ? 0 : timingTower.rowRightHalfWidthPx}px;
width: ${({ theme: { design: { timingTower } }, open }) =>
open ? timingTower.rowRightHalfWidthPx : 0}px;
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
overflow-x: clip;
background-color: #0000007e;
${({ transitionProps }) => commonTransition(transitionProps)}
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
`;
RowRightHalf.displayName = "RowRightHalf";
@@ -194,37 +191,46 @@ export const RowRightHalfLayout = styled.div`
`;
RowRightHalfLayout.displayName = "RowRightHalfLayout";
type DriverNameProps = {
visible: boolean,
};
export const DriverName = styled.span<DriverNameProps>`
export const DriverNameContainer = styled.div`
position: relative;
margin-left: ${p => p.theme.design.timingTower.nameLeftMargin}px;
`;
DriverNameContainer.displayName = "DriverNameContainer";
export const DriverName = styled.span<DirectionalTransitionProps>`
position: absolute;
top: 0;
left: 0;
opacity: ${({ visible }) => visible ? 1 : 0};
color: white;
font-family: ${p => p.theme.fonts.f1Bold};
font-size: 20px;
text-transform: uppercase;
opacity: ${({ open }) => open ? 1 : 0};
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
`;
DriverName.displayName = "DriverName";
export const DriverNameContainer = styled.div<TransitionProps>`
position: relative;
margin-left: ${p => p.theme.design.timingTower.nameLeftMargin}px;
export const DriverNameWipe = styled.div<DirectionalTransitionProps>`
/* background: #deadbe; */
> span {
${({ transitionProps }) => commonTransition(transitionProps)}
}
width: ${({ open }) => open ? 800 : 200}px;
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
mask-image: linear-gradient(to right, black 0, black 20%, transparent 30%);
mask-repeat: no-repeat;
opacity: ${({ open }) => open ? 1 : 0};
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
`;
DriverNameContainer.displayName = "DriverNameContainer";
DriverNameWipe.displayName = "DriverNameWipe";
type TimeDiffProps = TransitionProps & {
type TimeDiffProps = DirectionalTransitionProps & {
xScale: Fraction,
yScale: Fraction,
visible: boolean,
};
export const TimeDiff = styled.span<TimeDiffProps>`
color: white;
@@ -237,8 +243,9 @@ export const TimeDiff = styled.span<TimeDiffProps>`
transform-origin: top right;
transform: scale(${({ xScale, yScale }) => `${xScale}, ${yScale}`});
opacity: ${({ visible }) => visible ? 1 : 0};
${({ transitionProps }) => commonTransition(transitionProps)}
opacity: ${({ open }) => open ? 1 : 0};
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
`;
TimeDiff.displayName = "TimeDiff";