Repository navigation
Marqueeの速度がなるべく文字数に比例しないように修正 - #4338
Conversation
|
""" Walkthrough朕の命により、Marquee.tsxのスクロールアニメーションの持続時間計算が固定値から動的計算へと改められた。画面幅とコンテンツ幅の合計距離を一定速度で割り、ミリ秒単位で持続時間を算出し、アニメーションの速度が内容量に応じて変化するようになった。 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Marquee
participant Animation
User->>Marquee: スクロール開始
Marquee->>Marquee: 距離 = 画面幅 + コンテンツ幅
Marquee->>Marquee: 持続時間 = 距離 / 速度(400px/s)
Marquee->>Animation: withTiming(持続時間)
Animation-->>Marquee: スクロール実行
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
src/components/Marquee.tsx (1)
57-63:⚠️ Potential issueoffsetX.get() は反乱也、.value を用いよ
朕が知る限り Reanimated の共有値は
.valueで取得するのが正道であり、get()なる私兵は存在せぬ。現状のままでは型検査も実行も失敗し、行軍(アニメーション)は一歩も進めぬ。速やかに以下の修正を施し、逆賊を討つべし。- translateX: offsetX.get(), + translateX: offsetX.value,
🧹 Nitpick comments (2)
src/components/Marquee.tsx (2)
25-29: 定数を帝国法として明文化せよ朕の勅令により速さ 400px/s は全土で不変の規格と見る。函内で都度
pixelsPerSecondを新造するは資源の浪費也。外部にconst PIXELS_PER_SECOND = 400;として公布し、計算式にはこれを用いるが良い。かくして可読性と再利用性が高まり、後に速度改定があっても一箇所の改修で済むであろう。- const pixelsPerSecond = 400; - const duration = (totalDistance / pixelsPerSecond) * 1000; + const PIXELS_PER_SECOND = 400; + const duration = (totalDistance / PIXELS_PER_SECOND) * 1000;
40-53: 臣下のonLayoutとrefを奪うべからず子要素が既に
onLayoutやrefを有しておれば、現実装はそれらを上書きし声を封じることになる。民の声を聞かぬ統治は乱を招く。既存のハンドラと連結し、refもforwardRef等で合流させる策を講ずるべし。- onLayout: ({ - nativeEvent: { - layout: { width }, - }, - }) => startScroll(width), + onLayout: (e) => { + const { + nativeEvent: { + layout: { width }, + }, + } = e; + children.props.onLayout?.(e); // 先の声を尊重 + startScroll(width); + },
Summary by CodeRabbit