Spaces:
Running
Running
File size: 7,722 Bytes
b056989 6098e79 b056989 3242a9c 7867d9a 3242a9c b056989 6098e79 b056989 6098e79 a37eff3 6098e79 b056989 3242a9c b056989 718374f b056989 718374f b056989 2d83b1b b056989 6d6fd27 718374f b056989 e64799d 718374f b056989 e64799d 718374f b056989 718374f b056989 718374f b056989 a37eff3 718374f b056989 6098e79 7a9f07a b1a90c7 6098e79 b056989 6098e79 718374f b056989 6098e79 85c1b0c 6098e79 b056989 37bb41b 6098e79 85c1b0c 9bf5849 b056989 9bf5849 37bb41b 85c1b0c 9bf5849 a37eff3 9bf5849 37bb41b 9bf5849 b056989 a37eff3 9bf5849 37bb41b b056989 a37eff3 85c1b0c a37eff3 b056989 37bb41b b056989 a37eff3 b056989 37bb41b 9bf5849 b056989 37bb41b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Comparison Slider</title>
<link href="https://fonts.googleapis.com/css2?family=Saira:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--container-width: 80vw; /* Define a custom property for width */
}
body, html {
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: black;
color: white;
font-family: 'Saira', sans-serif;
}
.tabs {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.tab {
padding: 10px 20px;
background: rgba(255, 255, 255, 0.1);
border-radius: 5px;
cursor: pointer;
transition: background 0.3s;
font-weight: 500;
letter-spacing: 0.5px;
}
.tab:hover {
background: rgba(255, 255, 255, 0.2);
}
.tab.active {
background: rgb(0, 80, 150);
}
.video-container {
position: relative;
width: var(--container-width); /* Use the custom property for width */
height: calc(var(--container-width) * 9 / 16); /* Calculate height based on width */
overflow: hidden;
}
video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.second-video {
clip-path: inset(0 50% 0 0);
}
.slider {
position: absolute;
top: 0;
left: 30%;
width: 2px;
height: 100%;
background: rgb(0, 80, 150);
cursor: ew-resize;
z-index: 10;
animation: slide-animation 5s ease-in-out forwards;
border-radius: 4px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
}
.slider::before,
.slider::after {
content: '';
position: absolute;
top: 80%;
transform: translateY(-50%);
width: 30px;
height: 30px;
background-size: contain;
background-repeat: no-repeat;
transition: opacity 0.3s;
}
.slider::before {
left: -27px;
/* Simplified arrowhead pointing left */
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="rgb(0, 80, 150)"><polygon points="14,7 8,12 14,17"/></svg>');
}
.slider::after {
right: -27px;
/* Simplified arrowhead pointing right */
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="rgb(0, 80, 150)"><polygon points="10,7 16,12 10,17"/></svg>');
}
.slider.ready:hover::before,
.slider.ready:hover::after {
transform: translateY(-50%) scale(1.2);
}
.slider.ready::before,
.slider.ready::after {
opacity: 0.7;
}
.slider.ready:hover::before,
.slider.ready:hover::after {
opacity: 1;
}
@keyframes slide-animation {
0% {
left: 100%;
}
10% {
left: 80%;
}
20% {
left: 85%;
}
50% {
left: 20%;
}
70% {
left: 60%;
}
100% {
left: 30%;
}
}
</style>
</head>
<body>
<div class="tabs" id="tabs">
<div class="tab" data-page="SAILING_BOAT">Sailing Boat</div>
<div class="tab" data-page="MOB_NIGHT">MOB Night</div>
<div class="tab" data-page="BUOYS">Buoys</div>
<div class="tab" data-page="FAR_AWAY_OBJECT">Far Away Object</div>
</div>
<div class="video-container" id="videoContainer">
<video id="video1" playsinline autoplay loop muted></video>
<video id="video2" class="second-video" playsinline autoplay loop muted></video>
<div class="slider" id="slider"></div>
</div>
<script>
const slider = document.getElementById('slider');
const container = document.getElementById('videoContainer');
const video1 = document.getElementById('video1');
const video2 = document.getElementById('video2');
const tabs = document.getElementById('tabs');
let isDragging = false;
// Get current page from URL or default to SAILING_BOAT
const urlParams = new URLSearchParams(window.location.search);
let currentPage = urlParams.get('page') || 'SAILING_BOAT';
// Function to update video sources
function updateVideos(page) {
video1.src = `${page}/SEA-AI-Brain.mp4`;
video2.src = `${page}/FLIR.mp4`;
currentPage = page;
// Update URL without reloading
const newUrl = new URL(window.location);
newUrl.searchParams.set('page', page);
window.history.pushState({}, '', newUrl);
// Update active tab
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.toggle('active', tab.dataset.page === page);
});
}
// Tab click handlers
document.querySelectorAll('.tab').forEach(tab => {
tab.addEventListener('click', () => {
updateVideos(tab.dataset.page);
});
});
// Initialize with current page
updateVideos(currentPage);
// Mouse events for slider
slider.addEventListener('mousedown', () => isDragging = true);
window.addEventListener('mouseup', () => isDragging = false);
window.addEventListener('mousemove', (event) => {
if (!isDragging) return;
handleSlide(event.clientX);
});
// Touch events for slider
slider.addEventListener('touchstart', () => isDragging = true);
window.addEventListener('touchend', () => isDragging = false);
window.addEventListener('touchmove', (event) => {
if (!isDragging) return;
handleSlide(event.touches[0].clientX);
});
function handleSlide(positionX) {
const rect = container.getBoundingClientRect();
const offsetX = positionX - rect.left;
const sliderPosition = Math.max(0, Math.min(offsetX, rect.width));
slider.style.left = `${sliderPosition}px`;
video2.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
}
function updateClipPath() {
const rect = container.getBoundingClientRect();
const sliderPosition = parseFloat(window.getComputedStyle(slider).left);
video2.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
requestAnimationFrame(updateClipPath);
}
slider.addEventListener('animationend', () => {
slider.classList.add('ready');
slider.style.animation = 'none';
slider.style.cursor = 'ew-resize';
slider.style.pointerEvents = 'auto';
});
window.onload = () => updateClipPath();
</script>
</body>
</html> |