ISSUE-058 - First attempt at a wipe effect for the full last name display.

Discovered a limitation with WipeTransition and added a new optional prop for manual dimension definition.
Going to attempt using a mask image next instead as the animation fades the name in, not using a direct clip.
This commit is contained in:
Kyle Geib committed 2022-03-04 18:02:45 -05:00
1 parent b9e3447ff5
commit a38af0dec4
4 files changed
+40 -14

No files matched your search

@@ -1,7 +1,7 @@
import { animated, easings, useSpring } from "@react-spring/web";
import useMeasure from "react-use-measure";
import { Corner, Degrees, Fraction } from "../../../../types/style";
import { Corner, Degrees, Fraction, Px } from "../../../../types/style";
import { Milliseconds } from "../../../../types/util";
import { wipeCustomDegClip } from "../../../../utils/styling";
@@ -14,6 +14,10 @@ type WipeTransitionProps = {
opacityStart?: Fraction,
opacityDuration?: Milliseconds,
opacityDelay?: Milliseconds,
manualDimensions?: {
height: Px,
width: Px,
},
}
export function WipeTransition({
@@ -25,6 +29,7 @@ export function WipeTransition({
opacityStart = 1,
opacityDuration = duration,
opacityDelay = 0,
manualDimensions,
children,
}: React.PropsWithChildren<WipeTransitionProps>) {
const [childRef, {
@@ -53,8 +58,8 @@ export function WipeTransition({
opacity,
clipPath: wipe.to(wipeProgress => {
const coordinates = wipeCustomDegClip(
childWidth,
childHeight,
(manualDimensions?.width ?? 0) || childWidth,
(manualDimensions?.height ?? 0) || childHeight,
wipeProgress,
startingCorner,
angle,
@@ -147,12 +147,14 @@ export function TimingTowerRow({
yScale = rightHalfContent.includes("+") ? 1.1 : 1.0;
}
const { design: { timingTower: timingTowerTheme } } = theme;
return (
<AnimatedRowContainer
key={car.driver.id}
retired={car.status === CarStatus.Retired}
wide={displayMode !== BGTimingTowerDisplayMode.LeftOnly}
top={(car.position - 1) * theme.design.timingTower.rowHeightPx}
top={(car.position - 1) * timingTowerTheme.rowHeightPx}
transitionTime={TRAVEL_DURATION * DDM}
>
{car.notices.includes(CarNotice.FastestLap) && (
@@ -185,14 +187,14 @@ export function TimingTowerRow({
>
<RowLeftHalfLayout>
{car.status !== CarStatus.Retired && (
<RowLeftHalfPosFlagContainer size={32}>
<RowLeftHalfPosFlagContainer size={timingTowerTheme.posFlagSize}>
<PositionFlag
size={32}
size={timingTowerTheme.posFlagSize}
number={car.position}
numberSizeFraction={.6}
/>
<RowLeftHalfPosFlagChangeContainer
size={32}
size={timingTowerTheme.posFlagSize}
visible={showPosChange}
transitionTime={167 * DDM}
>
@@ -205,7 +207,7 @@ export function TimingTowerRow({
startingCorner="topLeft"
>
<PositionFlag
size={32}
size={timingTowerTheme.posFlagSize}
number={car.position}
numberSizeFraction={.6}
color={posChange > 0
@@ -221,19 +223,35 @@ export function TimingTowerRow({
<DriverNameContainer
transitionProps={[{
property: "opacity",
duration: FULL_WIDTH_DURATION * DDM,
duration: (FULL_WIDTH_DURATION - 333) * DDM,
delay: 333,
}]}
>
<DriverName visible={displayMode !== BGTimingTowerDisplayMode.FullLeft}>
{car.driver.initials}
</DriverName>
<DriverName visible={displayMode === BGTimingTowerDisplayMode.FullLeft}>
{car.driver.lastName}
</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,
}}
>
<DriverName visible={true}>
{car.driver.lastName}
</DriverName>
</WipeTransition>
</DriverNameContainer>
</RowLeftHalfLayout>
<RowLeftHalfGemContainer>
<TeamGem team={car.driver.team.id} height={30} />
<TeamGem team={car.driver.team.id} height={timingTowerTheme.teamGemSize} />
</RowLeftHalfGemContainer>
<AnimatedRowLeftHalfOutline
@@ -213,7 +213,7 @@ DriverName.displayName = "DriverName";
export const DriverNameContainer = styled.div<TransitionProps>`
position: relative;
margin-left: 14px;
margin-left: ${p => p.theme.design.timingTower.nameLeftMargin}px;
> span {
${({ transitionProps }) => commonTransition(transitionProps)}
+3
View File
@@ -72,6 +72,9 @@ export const theme = {
rowLeftHalfWidthPx: 147,
rowRightHalfWidthPx: 108,
retiredTopGapPx: 3,
teamGemSize: 30,
posFlagSize: 32,
nameLeftMargin: 14,
},
button: {
borderRadius: "0.25rem",