タグが見切れる問題対応 (#76) #395

マージ済み
みてるぞ が 7 個のコミットを feature/076 から main へマージ 2026-07-02 23:40:01 +09:00
コミット 57905672f8 の変更だけを表示してゐます - すべてのコミットを表示
+16 -11
ファイルの表示
@@ -12,7 +12,7 @@ const DESKTOP_MARQUEE_MEDIA =
'(min-width: 768px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference)' '(min-width: 768px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference)'
const MARQUEE_START_DELAY_MS = 1600 const MARQUEE_START_DELAY_MS = 1600
const MARQUEE_END_HOLD_MS = 2400 const MARQUEE_END_HOLD_MS = 2400
const MARQUEE_SCROLL_PX_PER_SECOND = 64 const MARQUEE_SCROLL_PX_PER_SECOND = 43
const MIN_MARQUEE_OVERFLOW_PX = 1 const MIN_MARQUEE_OVERFLOW_PX = 1
@@ -100,14 +100,19 @@ const ResponsiveMarqueeText: FC<Props> = ({ text, className, title }) => {
&& animated != null) && animated != null)
const resetAnimated = () => { const resetAnimated = () => {
const node = animatedRef.current
animationRef.current?.cancel () animationRef.current?.cancel ()
animationRef.current = null animationRef.current = null
node?.getAnimations?.().forEach (animation => {
animation.cancel ()
})
if (!(animated)) if (!(node))
return return
animated.style.transition = 'none' node.style.transition = 'none'
animated.style.transform = 'translateX(0)' node.style.transform = 'translateX(0)'
} }
if (!canMarquee) if (!canMarquee)
@@ -129,21 +134,15 @@ const ResponsiveMarqueeText: FC<Props> = ({ text, className, title }) => {
}) })
const runLoop = async () => { const runLoop = async () => {
let started = false
while (!cancelled) while (!cancelled)
{ {
resetAnimated () resetAnimated ()
if (!started) setMarqueeVisible (true)
setMarqueeVisible (false)
await sleep (MARQUEE_START_DELAY_MS) await sleep (MARQUEE_START_DELAY_MS)
if (cancelled || !(animatedRef.current)) if (cancelled || !(animatedRef.current))
break break
setMarqueeVisible (true)
started = true
const moveDurationMs = const moveDurationMs =
overflowPx / MARQUEE_SCROLL_PX_PER_SECOND * 1000 overflowPx / MARQUEE_SCROLL_PX_PER_SECOND * 1000
const node = animatedRef.current const node = animatedRef.current
@@ -165,6 +164,11 @@ const ResponsiveMarqueeText: FC<Props> = ({ text, className, title }) => {
{ {
break break
} }
node.style.transform = `translateX(-${ overflowPx }px)`
animation.cancel ()
if (animationRef.current === animation)
animationRef.current = null
} }
else else
{ {
@@ -178,6 +182,7 @@ const ResponsiveMarqueeText: FC<Props> = ({ text, className, title }) => {
}) })
await sleep (moveDurationMs) await sleep (moveDurationMs)
node.style.transition = 'none' node.style.transition = 'none'
node.style.transform = `translateX(-${ overflowPx }px)`
} }
if (cancelled) if (cancelled)