// Copyright 2026 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. import { useState } from "@lynx-js/react"; import { Danmaku } from "./components/Danmaku.jsx"; import { DEMO_MESSAGES, type DemoMessage } from "./mockData.js"; import "./App.scss"; const getMessageKey = (message: DemoMessage) => message.id; export function App() { const [messages, setMessages] = useState(DEMO_MESSAGES); const [autoScroll, setAutoScroll] = useState(true); const [selectedMessage, setSelectedMessage] = useState(null); const isRunning = autoScroll && messages.length > 0; const clearMessages = () => { setMessages([]); setAutoScroll(false); setSelectedMessage(null); }; const restoreMessages = () => { setMessages(DEMO_MESSAGES); setAutoScroll(true); setSelectedMessage(null); }; return ( CONTINUOUS LIST Live danmaku Four staggered lanes keep comments moving across the stage and loop without a visible jump. NOW PLAYING {messages.length} comments ยท tap any message {isRunning ? "AUTO" : "PAUSED"} setSelectedMessage(message)} renderItem={(message) => ( {message.label} )} /> LAST TAP {selectedMessage?.label ?? "No message selected"} messages.length > 0 && setAutoScroll((enabled) => !enabled)} > {autoScroll ? "Pause" : "Resume"} {messages.length === 0 ? "Restore" : "Clear lanes"} Drag or fling any lane to move all four together. Auto-scroll resumes after momentum ends. ); }