ISSUE-045 - Venetian Blinds - Added blinking animation for the position number.
Activated with a blink duration. I had to consider a manual delay before starting. The animation delay didn't really work as the number would be visible until the animation started. I'm sure there's a solution but I'm a little lazy to figure it out at the moment. Otherwise, for future reference: iirc the delay would be 250ms and the duration would be 400ms.
This commit is contained in:
1 parent
177272df6f
commit
b1b3b62d3a
4 files changed
+40
-10
No files matched your search
+6
-2
@@ -21,6 +21,7 @@ type VenetianBlindsTransitionProps = {
|
||||
opacityStart?: Fraction,
|
||||
opacityDuration?: Milliseconds,
|
||||
opacityDelay?: Milliseconds,
|
||||
spanBlinkDuration?: Milliseconds,
|
||||
};
|
||||
export const VenetianBlindsTransition = (
|
||||
{
|
||||
@@ -37,6 +38,7 @@ export const VenetianBlindsTransition = (
|
||||
opacityStart = 1,
|
||||
opacityDuration = wipeDuration,
|
||||
opacityDelay = 0,
|
||||
spanBlinkDuration,
|
||||
children,
|
||||
}: React.PropsWithChildren<VenetianBlindsTransitionProps>,
|
||||
) => {
|
||||
@@ -90,7 +92,8 @@ export const VenetianBlindsTransition = (
|
||||
blindsColor={blindsColor}
|
||||
blindsColorFadeDuration={blindsColorFadeDuration}
|
||||
blindsColorFadeDelay={blindsColorFadeDelay}
|
||||
blindsClosed={!!state}
|
||||
blindsClosing={!!state}
|
||||
spanBlinkDuration={spanBlinkDuration}
|
||||
mirror={true} // Mirror version provides the opposite blinds.
|
||||
>
|
||||
{children}
|
||||
@@ -102,7 +105,8 @@ export const VenetianBlindsTransition = (
|
||||
blindsColor={blindsColor}
|
||||
blindsColorFadeDuration={blindsColorFadeDuration}
|
||||
blindsColorFadeDelay={blindsColorFadeDelay}
|
||||
blindsClosed={!!state}
|
||||
blindsClosing={!!state}
|
||||
spanBlinkDuration={spanBlinkDuration}
|
||||
mirror={false}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
import { animated } from "@react-spring/web";
|
||||
import styled from "styled-components";
|
||||
import styled, { css, keyframes } from "styled-components";
|
||||
|
||||
import { Degrees, Px } from "../../../../types/style";
|
||||
import { Milliseconds } from "../../../../types/util";
|
||||
|
||||
const spanBlinkAnimation = keyframes`
|
||||
0% { opacity: 0 }
|
||||
62% { opacity: 1 }
|
||||
72% { opacity: 0 }
|
||||
81% { opacity: 1 }
|
||||
91% { opacity: 0 }
|
||||
100% { opacity: 1 }
|
||||
`;
|
||||
|
||||
type VenetianBlindsFilterProps = {
|
||||
blindsAngle: Degrees,
|
||||
transparentWidth: Px,
|
||||
@@ -11,8 +20,10 @@ type VenetianBlindsFilterProps = {
|
||||
blindsColor: string,
|
||||
blindsColorFadeDuration: Milliseconds,
|
||||
blindsColorFadeDelay?: Milliseconds,
|
||||
blindsClosed: boolean,
|
||||
blindsClosing: boolean,
|
||||
mirror?: boolean,
|
||||
spanBlinkDuration?: Milliseconds,
|
||||
spanBlinkDelay?: Milliseconds,
|
||||
};
|
||||
export const VenetianBlindsFilter = styled.div<VenetianBlindsFilterProps>`
|
||||
position: ${({ mirror }) => mirror ? "absolute" : null};
|
||||
@@ -29,13 +40,23 @@ export const VenetianBlindsFilter = styled.div<VenetianBlindsFilterProps>`
|
||||
);
|
||||
|
||||
> * {
|
||||
box-shadow: inset 0 0 0 99999px ${({ blindsColor, blindsClosed }) =>
|
||||
`${blindsColor}${blindsClosed ? "00" : "cc"}`};
|
||||
box-shadow: inset 0 0 0 99999px ${({ blindsColor, blindsClosing }) =>
|
||||
`${blindsColor}${blindsClosing ? "00" : "cc"}`};
|
||||
transition: box-shadow
|
||||
${({ blindsColorFadeDuration }) => blindsColorFadeDuration}ms
|
||||
cubic-bezier(0.88, 0.18, 0.96, 0.75)
|
||||
${({ blindsColorFadeDelay = 0 }) => blindsColorFadeDelay}ms;
|
||||
}
|
||||
|
||||
${({ blindsClosing, spanBlinkDuration }) => (
|
||||
blindsClosing && spanBlinkDuration
|
||||
? css`
|
||||
span {
|
||||
animation: ${spanBlinkAnimation} ${spanBlinkDuration}ms step-end;
|
||||
};
|
||||
`
|
||||
: null)
|
||||
}
|
||||
`;
|
||||
VenetianBlindsFilter.displayName = "VenetianBlindsFilter";
|
||||
|
||||
|
||||
Reference in new issue
Block a user