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