Spaces:
Running
Running
Update index.html
Browse files- index.html +20 -35
index.html
CHANGED
@@ -131,20 +131,30 @@
|
|
131 |
|
132 |
let isDragging = false;
|
133 |
|
134 |
-
slider.addEventListener('mousedown', () => {
|
135 |
-
isDragging = true;
|
136 |
-
});
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
|
|
|
|
141 |
|
142 |
window.addEventListener('mousemove', (event) => {
|
143 |
if (!isDragging) return;
|
|
|
|
|
144 |
|
145 |
-
|
146 |
-
|
|
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
const sliderPosition = Math.max(0, Math.min(offsetX, rect.width));
|
149 |
|
150 |
// Move slider position
|
@@ -152,7 +162,7 @@
|
|
152 |
|
153 |
// Adjust second video visibility using clip-path
|
154 |
secondVideo.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
|
155 |
-
}
|
156 |
|
157 |
// Function to update clip-path in real-time
|
158 |
function updateClipPath() {
|
@@ -168,35 +178,10 @@
|
|
168 |
slider.style.animation = 'none';
|
169 |
slider.style.cursor = 'ew-resize';
|
170 |
slider.style.pointerEvents = 'auto';
|
171 |
-
|
172 |
-
// User interaction
|
173 |
-
let isDragging = false;
|
174 |
-
|
175 |
-
slider.addEventListener('mousedown', () => {
|
176 |
-
isDragging = true;
|
177 |
-
});
|
178 |
-
|
179 |
-
window.addEventListener('mouseup', () => {
|
180 |
-
isDragging = false;
|
181 |
-
});
|
182 |
-
|
183 |
-
window.addEventListener('mousemove', (event) => {
|
184 |
-
if (!isDragging) return;
|
185 |
-
|
186 |
-
const rect = container.getBoundingClientRect();
|
187 |
-
const offsetX = event.clientX - rect.left;
|
188 |
-
const sliderPosition = Math.max(0, Math.min(offsetX, rect.width));
|
189 |
-
|
190 |
-
// Move slider position and update video visibility
|
191 |
-
slider.style.left = `${sliderPosition}px`;
|
192 |
-
secondVideo.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
|
193 |
-
});
|
194 |
});
|
195 |
|
196 |
// Start updating clip-path once the page loads
|
197 |
-
window.onload = () =>
|
198 |
-
updateClipPath();
|
199 |
-
};
|
200 |
</script>
|
201 |
</body>
|
202 |
|
|
|
131 |
|
132 |
let isDragging = false;
|
133 |
|
|
|
|
|
|
|
134 |
|
135 |
+
let isDragging = false;
|
136 |
+
|
137 |
+
// Mouse events
|
138 |
+
slider.addEventListener('mousedown', () => isDragging = true);
|
139 |
+
window.addEventListener('mouseup', () => isDragging = false);
|
140 |
|
141 |
window.addEventListener('mousemove', (event) => {
|
142 |
if (!isDragging) return;
|
143 |
+
handleSlide(event.clientX);
|
144 |
+
});
|
145 |
|
146 |
+
// Touch events
|
147 |
+
slider.addEventListener('touchstart', () => isDragging = true);
|
148 |
+
window.addEventListener('touchend', () => isDragging = false);
|
149 |
|
150 |
+
window.addEventListener('touchmove', (event) => {
|
151 |
+
if (!isDragging) return;
|
152 |
+
handleSlide(event.touches[0].clientX); // Get the X position from the first touch point
|
153 |
+
});
|
154 |
+
|
155 |
+
function handleSlide(positionX) {
|
156 |
+
const rect = container.getBoundingClientRect();
|
157 |
+
const offsetX = positionX - rect.left;
|
158 |
const sliderPosition = Math.max(0, Math.min(offsetX, rect.width));
|
159 |
|
160 |
// Move slider position
|
|
|
162 |
|
163 |
// Adjust second video visibility using clip-path
|
164 |
secondVideo.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
|
165 |
+
}
|
166 |
|
167 |
// Function to update clip-path in real-time
|
168 |
function updateClipPath() {
|
|
|
178 |
slider.style.animation = 'none';
|
179 |
slider.style.cursor = 'ew-resize';
|
180 |
slider.style.pointerEvents = 'auto';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
});
|
182 |
|
183 |
// Start updating clip-path once the page loads
|
184 |
+
window.onload = () => updateClipPath();
|
|
|
|
|
185 |
</script>
|
186 |
</body>
|
187 |
|