Skip to content

Commit f38adc6

Browse files
committed
Feature: Prevent timer animation on mobile
1 parent 991544b commit f38adc6

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

components/BottomSheet/contents/BottomSheetTimer/BottomSheetTimer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function BottomSheetTimer({
88
return (
99
<ContentContainer>
1010
<Timer
11+
disableAnimation={true}
1112
onTimingStart={() => {
1213
hideBottomSheet();
1314
}}

components/Timer/Timer.styled.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import styled from "@emotion/styled";
2-
import { keyframes } from "@emotion/react";
2+
import { css, keyframes } from "@emotion/react";
3+
import { Theme } from "../../styles/theme";
34

45
const TimerFadeKeyframe = keyframes`
56
from {
@@ -13,7 +14,11 @@ const TimerFadeKeyframe = keyframes`
1314
}
1415
`;
1516

16-
export const Container = styled.div`
17+
export const TimerFadeAnimationCSS = css`
18+
animation: ${TimerFadeKeyframe} 0.4s cubic-bezier(0.2, 0, 0, 1) 0.5s forwards;
19+
`;
20+
21+
export const Container = styled.div<{ disableAnimation: boolean }>`
1722
display: flex;
1823
flex-direction: column;
1924
align-items: flex-end;
@@ -30,12 +35,14 @@ export const Container = styled.div`
3035
gap: 30px;
3136
}
3237
33-
opacity: 0;
34-
transform: translate3d(0, 30px, 0);
35-
animation: ${TimerFadeKeyframe} 0.4s cubic-bezier(0.2, 0, 0, 1) 0.5s forwards;
38+
opacity: ${(props) => (props.disableAnimation ? "1" : "0")};
39+
transform: translate3d(
40+
0,
41+
${(props) => (props.disableAnimation ? "0" : "30px")},
42+
0
43+
);
3644
37-
@media screen and (max-width: ${({ theme }) =>
38-
theme.responsiveSizes.hideTimer}px) {
45+
@media screen and (max-width: ${Theme.responsiveSizes.hideTimer}px) {
3946
justify-content: center;
4047
flex-direction: row-reverse;
4148

components/Timer/Timer.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import {
55
isClockPointerDownAtom as ICPD,
66
isTimingNowAtom as ITN,
77
languageOptionValueAtom as LOV,
8-
progressUnitValueAtom as PUV,
98
maxClockTimeAtom as MCT,
109
} from "../../shared/atom";
11-
import { Container } from "./Timer.styled";
10+
import { Container, TimerFadeAnimationCSS } from "./Timer.styled";
1211
import "firebase/messaging";
1312
import RoundButton from "../Button/RoundButton/RoundButton";
1413
import useMediaMatch from "../../hooks/useMediaMatch";
1514
import { Theme } from "../../styles/theme";
16-
import { IProps } from "./Timer.type";
15+
import { ITimerProps } from "./Timer.type";
1716
import useRecordManager from "../../hooks/useRecordManager";
1817
import TimerOption from "../TimerOption/TimerOption";
1918
import TimeText from "../TimeText/TimeText";
@@ -23,7 +22,10 @@ let startTime: Date | null = null;
2322
let startDegree: number = 0;
2423
let isPausedBefore: boolean = false;
2524

26-
export default function Timer({ onTimingStart }: IProps) {
25+
export default function Timer({
26+
onTimingStart,
27+
disableAnimation = false,
28+
}: ITimerProps) {
2729
const isClockPointerDown = useRecoilValue(ICPD);
2830
const language = useRecoilValue(LOV);
2931
const maxClockTime = useRecoilValue(MCT);
@@ -99,7 +101,10 @@ export default function Timer({ onTimingStart }: IProps) {
99101
}, [isTimingNow]);
100102

101103
return (
102-
<Container>
104+
<Container
105+
css={disableAnimation ? null : TimerFadeAnimationCSS}
106+
disableAnimation={disableAnimation}
107+
>
103108
<div className="option-container">
104109
{isHideTimer ? null : (
105110
<RoundButton

components/Timer/Timer.type.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
export interface IProps {
1+
export interface ITimerProps {
22
onTimingStart?: () => void;
3+
disableAnimation?: boolean;
34
}

components/pages/records/RecordLogs/RecordLogs.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useQuery } from "@tanstack/react-query";
22
import { useMemo } from "react";
3-
import { FaBoxOpen } from "react-icons/fa";
43
import { useRecoilValue } from "recoil";
54
import {
65
getTimeRecordsFromDB,

0 commit comments

Comments
 (0)