Skip to content

Commit 69bd7a3

Browse files
committed
up
1 parent 60747a8 commit 69bd7a3

File tree

2 files changed

+120
-30
lines changed

2 files changed

+120
-30
lines changed

index.html

Lines changed: 86 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,18 +1576,10 @@
15761576
window.addEventListener('load', function() {
15771577
const timelineSlider = document.getElementById('timelineSlider');
15781578
if (timelineSlider) {
1579-
timelineSlider.style.setProperty('background', '#5a8a2a', 'important');
1580-
timelineSlider.style.backgroundColor = '#5a8a2a';
1581-
timelineSlider.style.background = '#5a8a2a';
1582-
1583-
// Add dynamic styles
1579+
// Add dynamic styles for thumb
15841580
const dynamicStyle = document.createElement('style');
15851581
dynamicStyle.id = 'timeline-green-style';
15861582
dynamicStyle.textContent = `
1587-
#timelineSlider {
1588-
background: #5a8a2a !important;
1589-
background-color: #5a8a2a !important;
1590-
}
15911583
#timelineSlider::-webkit-slider-thumb {
15921584
background: #5a8a2a !important;
15931585
}
@@ -2038,13 +2030,17 @@
20382030
timelineSlider.value = point;
20392031
frameVideo.currentTime = point;
20402032
updateTimeDisplay(point);
2033+
lastUpdateTime = 0;
2034+
updateProgressBarColor();
20412035
});
20422036

20432037
// Click key point to also jump
20442038
keyPoint.addEventListener('click', function() {
20452039
timelineSlider.value = point;
20462040
frameVideo.currentTime = point;
20472041
updateTimeDisplay(point);
2042+
lastUpdateTime = 0;
2043+
updateProgressBarColor();
20482044
});
20492045

20502046
// Add to timelineMarks container
@@ -2058,12 +2054,27 @@
20582054
const time = parseFloat(this.value);
20592055
frameVideo.currentTime = time;
20602056
updateTimeDisplay(time);
2057+
// Force immediate update for user input
2058+
lastUpdateTime = 0;
2059+
updateProgressBarColor();
20612060
});
20622061

2062+
// Throttle function for performance
2063+
let lastUpdateTime = 0;
2064+
const throttleDelay = 50; // Update at most every 50ms
2065+
20632066
// Video time update events
20642067
frameVideo.addEventListener('timeupdate', function() {
2065-
timelineSlider.value = this.currentTime;
2066-
updateTimeDisplay(this.currentTime);
2068+
const currentTime = this.currentTime;
2069+
timelineSlider.value = currentTime;
2070+
updateTimeDisplay(currentTime);
2071+
2072+
// Throttle progress bar color updates
2073+
const now = Date.now();
2074+
if (now - lastUpdateTime >= throttleDelay) {
2075+
updateProgressBarColor();
2076+
lastUpdateTime = now;
2077+
}
20672078
});
20682079

20692080
// Update time display
@@ -2075,40 +2086,95 @@
20752086
`${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}.${milliseconds.toString().padStart(2, '0')}`;
20762087
}
20772088

2078-
// Force set timeline color - multiple safeguards
2079-
timelineSlider.style.setProperty('background', '#5a8a2a', 'important');
2080-
timelineSlider.style.backgroundColor = '#5a8a2a';
2081-
timelineSlider.style.background = '#5a8a2a';
2089+
// Update progress bar color (green for reached, gray for unreached)
2090+
let lastPercentage = -1; // Track last percentage to avoid unnecessary updates
2091+
function updateProgressBarColor() {
2092+
const value = parseFloat(timelineSlider.value) || 0;
2093+
const max = parseFloat(timelineSlider.max) || 25;
2094+
if (max <= 0) return; // Don't update if max is invalid
2095+
2096+
const percentage = Math.max(0, Math.min(100, (value / max) * 100));
2097+
2098+
// Only update if percentage changed significantly (avoid unnecessary updates)
2099+
if (Math.abs(percentage - lastPercentage) < 0.1 && lastPercentage >= 0) {
2100+
return;
2101+
}
2102+
lastPercentage = percentage;
2103+
2104+
// Get or create style element - always use the same ID
2105+
let trackStyle = document.getElementById('timeline-track-style');
2106+
if (!trackStyle) {
2107+
trackStyle = document.createElement('style');
2108+
trackStyle.id = 'timeline-track-style';
2109+
// Insert at the end of head to ensure highest priority
2110+
document.head.appendChild(trackStyle);
2111+
}
2112+
2113+
// Use layered backgrounds: green on top, gray below
2114+
// Use !important to override any static CSS
2115+
// Set both background and background-image for maximum compatibility
2116+
const gradient = `linear-gradient(to right, #5a8a2a 0%, #5a8a2a ${percentage}%, transparent ${percentage}%, transparent 100%)`;
2117+
2118+
// Force update by removing and re-adding the style element
2119+
// This ensures the browser re-applies the styles
2120+
if (trackStyle.parentNode) {
2121+
trackStyle.parentNode.removeChild(trackStyle);
2122+
}
2123+
trackStyle = document.createElement('style');
2124+
trackStyle.id = 'timeline-track-style';
2125+
trackStyle.textContent = `
2126+
#timelineSlider::-webkit-slider-runnable-track {
2127+
background: #ccc !important;
2128+
background-image: ${gradient} !important;
2129+
background-size: 100% 100% !important;
2130+
background-repeat: no-repeat !important;
2131+
background-position: 0 0 !important;
2132+
}
2133+
#timelineSlider::-moz-range-track {
2134+
background: #ccc !important;
2135+
background-image: ${gradient} !important;
2136+
background-size: 100% 100% !important;
2137+
background-repeat: no-repeat !important;
2138+
background-position: 0 0 !important;
2139+
}
2140+
`;
2141+
// Append to end of head for highest priority
2142+
document.head.appendChild(trackStyle);
2143+
}
20822144

2083-
// Set slider thumb color
2145+
// Set slider thumb color and positioning
20842146
const style = document.createElement('style');
20852147
style.textContent = `
20862148
#timelineSlider::-webkit-slider-thumb {
20872149
background: #5a8a2a !important;
2150+
margin-top: -6px !important;
20882151
}
20892152
#timelineSlider::-moz-range-thumb {
20902153
background: #5a8a2a !important;
20912154
}
2092-
#timelineSlider {
2093-
background: #5a8a2a !important;
2094-
}
20952155
`;
20962156
document.head.appendChild(style);
20972157

2158+
// Initialize progress bar color
2159+
updateProgressBarColor();
2160+
20982161
// Initialize
20992162
timelineSlider.max = frameVideo.duration || 30;
21002163
updateTimeDisplay(0);
2164+
updateProgressBarColor();
21012165

21022166
// Ensure initialization after video loads
21032167
frameVideo.addEventListener('loadedmetadata', function() {
21042168
timelineSlider.max = this.duration;
21052169
updateTimeDisplay(0);
2170+
updateProgressBarColor();
21062171
});
21072172

21082173
// If video is already loaded, initialize immediately
21092174
if (frameVideo.readyState >= 1) {
21102175
timelineSlider.max = frameVideo.duration;
21112176
updateTimeDisplay(0);
2177+
updateProgressBarColor();
21122178
}
21132179
}
21142180
});
@@ -3674,7 +3740,7 @@ <h2 class="title is-3" style="text-align: center; color: #3a6902;">Goal Reaching
36743740
<h4 style="text-align: center; margin-bottom: 15px; font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif);">Click image for real-world goal pose, click ▶ for natural transition, and drag the progress bar to view frame by frame.</h4>
36753741
<div class="video-timeline-container">
36763742
<div class="timeline-marks" id="timelineMarks"></div>
3677-
<input type="range" id="timelineSlider" class="timeline-slider" min="0" max="25" step="0.1" value="0" style="background: #5a8a2a !important;">
3743+
<input type="range" id="timelineSlider" class="timeline-slider" min="0" max="25" step="0.1" value="0" style="background: #ccc;">
36783744
<div class="timeline-current-time" id="currentTime">00:00.00</div>
36793745
</div>
36803746

static/css/index.css

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ body {
323323
background: rgba(0, 0, 0, 0.5);
324324
}
325325

326-
.play-button {
326+
/* Video cover play button - use specific selector to avoid conflicts with timeline play button */
327+
.video-cover .play-button {
327328
width: 60px;
328329
height: 60px;
329330
background: rgba(0, 123, 255, 0.9) !important;
@@ -334,7 +335,7 @@ body {
334335
transition: transform 0.3s ease, background-color 0.3s ease;
335336
}
336337

337-
.play-button i {
338+
.video-cover .play-button i {
338339
font-size: 24px;
339340
color: white;
340341
margin-left: 4px;
@@ -921,14 +922,34 @@ body {
921922
.timeline-slider {
922923
width: 96%;
923924
height: 8px;
924-
background: #5a8a2a;
925+
background: #ccc;
925926
border-radius: 4px;
926927
outline: none;
927928
position: absolute;
928929
top: 30px;
929930
left: 50%;
930931
transform: translateX(-50%);
931932
margin: 70px 0 0 0;
933+
-webkit-appearance: none;
934+
appearance: none;
935+
}
936+
937+
.timeline-slider::-webkit-slider-runnable-track {
938+
width: 100%;
939+
height: 8px;
940+
background: #ccc;
941+
border-radius: 4px;
942+
-webkit-appearance: none;
943+
/* Dynamic styles will override this */
944+
}
945+
946+
.timeline-slider::-moz-range-track {
947+
width: 100%;
948+
height: 8px;
949+
background: #ccc;
950+
border-radius: 4px;
951+
-moz-appearance: none;
952+
/* Dynamic styles will override this */
932953
}
933954

934955
.timeline-slider::-webkit-slider-thumb {
@@ -940,6 +961,7 @@ body {
940961
border-radius: 50%;
941962
cursor: pointer;
942963
box-shadow: 0 2px 6px rgba(0,0,0,0.3);
964+
margin-top: -6px; /* Center the thumb on the track (track height 8px, thumb height 20px, so offset by (20-8)/2 = 6px) */
943965
}
944966

945967
.timeline-slider::-moz-range-thumb {
@@ -992,6 +1014,7 @@ input[type="range"].slider.slider-vertical::-moz-range-thumb {
9921014

9931015
.video-timeline-container .timeline-slider::-webkit-slider-thumb {
9941016
background: #5a8a2a !important;
1017+
margin-top: -6px !important;
9951018
}
9961019

9971020
.video-timeline-container .timeline-slider::-moz-range-thumb {
@@ -1010,14 +1033,15 @@ input[type="range"].slider.slider-vertical::-moz-range-thumb {
10101033
}
10111034

10121035
/* Play button styles */
1013-
.play-button {
1036+
/* Goal Reaching timeline play button - use specific selector to avoid conflicts */
1037+
.video-timeline-container .play-button {
10141038
position: absolute;
10151039
top: 175px;
10161040
left: 10px;
10171041
width: 40px;
10181042
height: 40px;
1019-
background: #3a6902;
1020-
border: none;
1043+
background: #3a6902 !important;
1044+
border: none !important;
10211045
border-radius: 50%;
10221046
color: white;
10231047
font-size: 16px;
@@ -1030,17 +1054,17 @@ input[type="range"].slider.slider-vertical::-moz-range-thumb {
10301054
z-index: 20;
10311055
}
10321056

1033-
.play-button:hover {
1034-
background: #2d4f02;
1057+
.video-timeline-container .play-button:hover {
1058+
background: #2d4f02 !important;
10351059
transform: scale(1.1);
10361060
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
10371061
}
10381062

1039-
.play-button.paused::before {
1063+
.video-timeline-container .play-button.paused::before {
10401064
content: '▶';
10411065
}
10421066

1043-
.play-button.playing::before {
1067+
.video-timeline-container .play-button.playing::before {
10441068
content: '⏸';
10451069
}
10461070

0 commit comments

Comments
 (0)