kevinconka commited on
Commit
37bb41b
·
verified ·
1 Parent(s): 2d83b1b

Remove sync logic, does not seem worth it

Browse files
Files changed (1) hide show
  1. index.html +7 -17
index.html CHANGED
@@ -113,24 +113,9 @@
113
  <script>
114
  const slider = document.getElementById('slider');
115
  const container = document.getElementById('videoContainer');
116
- const video1 = document.getElementById('video1');
117
  const video2 = document.getElementById('video2');
118
  let isDragging = false;
119
- const syncTolerance = 0.1; // Tolerance in seconds for syncing
120
- // Function to sync the second video to the first video
121
- function syncVideos(mainVideo, secondaryVideo) {
122
- if (Math.abs(mainVideo.currentTime - secondaryVideo.currentTime) > syncTolerance) {
123
- secondaryVideo.currentTime = mainVideo.currentTime;
124
- }
125
- if (mainVideo.paused && !secondaryVideo.paused) {
126
- secondaryVideo.pause();
127
- } else if (!mainVideo.paused && secondaryVideo.paused) {
128
- secondaryVideo.play();
129
- }
130
- }
131
- // Set up timeupdate event listeners for smoother sync
132
- video1.addEventListener('timeupdate', () => syncVideos(video1, video2));
133
- video2.addEventListener('timeupdate', () => syncVideos(video2, video1));
134
  // Mouse events for slider
135
  slider.addEventListener('mousedown', () => isDragging = true);
136
  window.addEventListener('mouseup', () => isDragging = false);
@@ -138,6 +123,7 @@
138
  if (!isDragging) return;
139
  handleSlide(event.clientX);
140
  });
 
141
  // Touch events for slider
142
  slider.addEventListener('touchstart', () => isDragging = true);
143
  window.addEventListener('touchend', () => isDragging = false);
@@ -145,6 +131,7 @@
145
  if (!isDragging) return;
146
  handleSlide(event.touches[0].clientX);
147
  });
 
148
  function handleSlide(positionX) {
149
  const rect = container.getBoundingClientRect();
150
  const offsetX = positionX - rect.left;
@@ -154,6 +141,7 @@
154
  // Adjust second video visibility using clip-path
155
  video2.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
156
  }
 
157
  // Function to update clip-path in real-time
158
  function updateClipPath() {
159
  const rect = container.getBoundingClientRect();
@@ -161,6 +149,7 @@
161
  video2.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
162
  requestAnimationFrame(updateClipPath);
163
  }
 
164
  // Enable user control after the animation ends
165
  slider.addEventListener('animationend', () => {
166
  slider.classList.add('ready');
@@ -168,8 +157,9 @@
168
  slider.style.cursor = 'ew-resize';
169
  slider.style.pointerEvents = 'auto';
170
  });
 
171
  // Start updating clip-path once the page loads
172
  window.onload = () => updateClipPath();
173
  </script>
174
  </body>
175
- </html>
 
113
  <script>
114
  const slider = document.getElementById('slider');
115
  const container = document.getElementById('videoContainer');
 
116
  const video2 = document.getElementById('video2');
117
  let isDragging = false;
118
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  // Mouse events for slider
120
  slider.addEventListener('mousedown', () => isDragging = true);
121
  window.addEventListener('mouseup', () => isDragging = false);
 
123
  if (!isDragging) return;
124
  handleSlide(event.clientX);
125
  });
126
+
127
  // Touch events for slider
128
  slider.addEventListener('touchstart', () => isDragging = true);
129
  window.addEventListener('touchend', () => isDragging = false);
 
131
  if (!isDragging) return;
132
  handleSlide(event.touches[0].clientX);
133
  });
134
+
135
  function handleSlide(positionX) {
136
  const rect = container.getBoundingClientRect();
137
  const offsetX = positionX - rect.left;
 
141
  // Adjust second video visibility using clip-path
142
  video2.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
143
  }
144
+
145
  // Function to update clip-path in real-time
146
  function updateClipPath() {
147
  const rect = container.getBoundingClientRect();
 
149
  video2.style.clipPath = `inset(0 ${rect.width - sliderPosition}px 0 0)`;
150
  requestAnimationFrame(updateClipPath);
151
  }
152
+
153
  // Enable user control after the animation ends
154
  slider.addEventListener('animationend', () => {
155
  slider.classList.add('ready');
 
157
  slider.style.cursor = 'ew-resize';
158
  slider.style.pointerEvents = 'auto';
159
  });
160
+
161
  // Start updating clip-path once the page loads
162
  window.onload = () => updateClipPath();
163
  </script>
164
  </body>
165
+ </html>