Add buttons next/prev/top/end

This commit is contained in:
2026-03-05 18:09:00 +08:00
parent 3a545952c0
commit b27ec2088c
2 changed files with 97 additions and 2 deletions

View File

@@ -42,12 +42,18 @@ body {
} }
.nav-left, .nav-left,
.nav-right { .nav-right,
.nav-center {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
} }
.nav-center {
flex: 1;
justify-content: center;
}
.nav-btn { .nav-btn {
width: 40px; width: 40px;
height: 40px; height: 40px;

View File

@@ -23,7 +23,31 @@
</svg> </svg>
</button> </button>
</div> </div>
<div class="nav-center">
<button class="nav-btn" id="firstBtn" title="First Line">
<svg viewBox="0 0 24 24" fill="none" stroke-width="2">
<path d="M11 18l-6-6 6-6"/>
<path d="M4 18V6"/>
</svg>
</button>
<button class="nav-btn" id="prevBtn" title="Previous Line">
<svg viewBox="0 0 24 24" fill="none" stroke-width="2">
<path d="M15 18l-6-6 6-6"/>
</svg>
</button>
<span class="nav-title" id="timeDisplay">00:00</span> <span class="nav-title" id="timeDisplay">00:00</span>
<button class="nav-btn" id="nextBtn" title="Next Line">
<svg viewBox="0 0 24 24" fill="none" stroke-width="2">
<path d="M9 18l6-6-6-6"/>
</svg>
</button>
<button class="nav-btn" id="lastBtn" title="Last Line">
<svg viewBox="0 0 24 24" fill="none" stroke-width="2">
<path d="M13 18l6-6-6-6"/>
<path d="M20 18V6"/>
</svg>
</button>
</div>
<div class="nav-right"> <div class="nav-right">
<button class="nav-btn" id="playPauseBtn" title="Play/Pause"> <button class="nav-btn" id="playPauseBtn" title="Play/Pause">
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" id="playIcon"> <svg viewBox="0 0 24 24" fill="none" stroke-width="2" id="playIcon">
@@ -108,6 +132,10 @@
const playIcon = document.getElementById('playIcon'); const playIcon = document.getElementById('playIcon');
const pauseIcon = document.getElementById('pauseIcon'); const pauseIcon = document.getElementById('pauseIcon');
const goToBtn = document.getElementById('goToBtn'); const goToBtn = document.getElementById('goToBtn');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const firstBtn = document.getElementById('firstBtn');
const lastBtn = document.getElementById('lastBtn');
let selectedLine = null; let selectedLine = null;
let expandedLine = null; let expandedLine = null;
@@ -251,6 +279,61 @@
} }
} }
// Go to previous line
function goToPreviousLine() {
if (lines.length === 0) return;
pausePlayback();
const newIndex = Math.max(0, currentLineIndex - 1);
currentLineIndex = newIndex;
updateSelection(currentLineIndex);
updateBlurStates();
const targetLine = lines[currentLineIndex];
currentTime = getLineTimeSeconds(targetLine);
updateTimeDisplay();
scrollToLine(targetLine);
}
// Go to next line
function goToNextLine() {
if (lines.length === 0) return;
pausePlayback();
const newIndex = Math.min(lines.length - 1, currentLineIndex + 1);
currentLineIndex = newIndex;
updateSelection(currentLineIndex);
updateBlurStates();
const targetLine = lines[currentLineIndex];
currentTime = getLineTimeSeconds(targetLine);
updateTimeDisplay();
scrollToLine(targetLine);
}
// Go to first line
function goToFirstLine() {
if (lines.length === 0) return;
pausePlayback();
currentLineIndex = 0;
updateSelection(0);
updateBlurStates();
const targetLine = lines[0];
currentTime = getLineTimeSeconds(targetLine);
updateTimeDisplay();
scrollToLine(targetLine);
}
// Go to last line
function goToLastLine() {
if (lines.length === 0) return;
pausePlayback();
const lastIndex = lines.length - 1;
currentLineIndex = lastIndex;
updateSelection(lastIndex);
updateBlurStates();
const targetLine = lines[lastIndex];
currentTime = getLineTimeSeconds(targetLine);
updateTimeDisplay();
scrollToLine(targetLine);
}
// Interactive drag-to-reveal for blur overlay // Interactive drag-to-reveal for blur overlay
const SWIPE_THRESHOLD = 160; // pixels to trigger reveal const SWIPE_THRESHOLD = 160; // pixels to trigger reveal
let activeDrag = null; // Track which line is being dragged let activeDrag = null; // Track which line is being dragged
@@ -433,6 +516,12 @@
// Go to button // Go to button
goToBtn.addEventListener('click', goToCurrentLine); goToBtn.addEventListener('click', goToCurrentLine);
// Navigation buttons
prevBtn.addEventListener('click', goToPreviousLine);
nextBtn.addEventListener('click', goToNextLine);
firstBtn.addEventListener('click', goToFirstLine);
lastBtn.addEventListener('click', goToLastLine);
// Open side menu // Open side menu
function openMenu() { function openMenu() {
sideMenu.classList.add('active'); sideMenu.classList.add('active');