fix(#watermark): visible 1 time at 5 sec

keep-around/fdb88b04b32b9392e76795099e2ec47c9856b38b
Andrei Dekterev 3 years ago
parent b5f1b489f9
commit fdb88b04b3
  1. 52
      src/components/WaterMark/index.tsx
  2. 2
      src/features/TournamentList/components/TournamentMobile/styled.tsx

@ -2,8 +2,9 @@ import { useState, useEffect } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
type WmType = { type WmType = {
leftWm?: number, leftWm: number,
topWm?: number, topWm: number,
visible: boolean,
} }
export const ScWaterMark = styled.div<WmType>` export const ScWaterMark = styled.div<WmType>`
@ -11,22 +12,10 @@ export const ScWaterMark = styled.div<WmType>`
top: ${({ topWm }) => `${topWm}%`}; top: ${({ topWm }) => `${topWm}%`};
left: ${({ leftWm }) => `${leftWm}%`}; left: ${({ leftWm }) => `${leftWm}%`};
z-index: 1; z-index: 1;
width: 100%; opacity: 1;
opacity: 0.2;
color: white; color: white;
//animation: marquee 2s linear; visibility: ${({ visible }) => (visible ? 'visible'
// : 'hidden')};
//@keyframes marquee {
// 0% {
// opacity: 0;
// }
// 50% {
// opacity: 0.3;
// }
// 100% {
// opacity: 0;
// }
//}
` `
type WaterMarkProps = { type WaterMarkProps = {
@ -36,26 +25,25 @@ type WaterMarkProps = {
export const WaterMark = ({ value }: WaterMarkProps) => { export const WaterMark = ({ value }: WaterMarkProps) => {
const [topWm, setTopWm] = useState(0) const [topWm, setTopWm] = useState(0)
const [leftWm, setLeftWm] = useState(0) const [leftWm, setLeftWm] = useState(0)
const [topWm2, setTopWm2] = useState(0) const [visible, setVisible] = useState(false)
const [leftWm2, setLeftWm2] = useState(0)
useEffect(() => { useEffect(() => {
let getIntervalCoordinates: ReturnType<typeof setInterval> setInterval(() => {
// eslint-disable-next-line setLeftWm(Math.floor(Math.random() * 95))
getIntervalCoordinates = setInterval( setTopWm(Math.floor(Math.random() * 95))
() => { setVisible((v) => !v)
setLeftWm(Math.floor(Math.random() * 95)) }, 1000 * 5)
setTopWm(Math.floor(Math.random() * 10))
setLeftWm2(Math.floor(Math.random() * 95))
setTopWm2(Math.floor(Math.random() * (10)) + 80)
}, 1000 * 60 * 3,
)
return () => clearInterval(getIntervalCoordinates)
}, []) }, [])
return ( return (
<> <>
<ScWaterMark topWm={topWm} leftWm={leftWm}>{value}</ScWaterMark> <ScWaterMark
<ScWaterMark topWm={topWm2} leftWm={leftWm2}>{value}</ScWaterMark> visible={visible}
topWm={topWm}
leftWm={leftWm}
>
{value}
</ScWaterMark>
</> </>
) )
} }

@ -50,7 +50,7 @@ export const TournamentName = styled(Name)`
white-space: nowrap; white-space: nowrap;
@media (orientation: portrait) { @media (orientation: portrait) {
max-width: 200px; max-width: 150px;
} }
` `

Loading…
Cancel
Save