John2121 commited on
Commit
fb7d3dc
·
verified ·
1 Parent(s): 2114eed

InstallTrigger is deprecated and will be removed in the future. library.js:31:5

Browse files
Files changed (1) hide show
  1. script.js +17 -17
script.js CHANGED
@@ -52,10 +52,8 @@ class RabbitHole {
52
  }
53
  ];
54
  this.currentStep = 0;
55
-
56
- this.init();
57
  }
58
-
59
  init() {
60
  this.createParticles();
61
  this.bindEvents();
@@ -94,7 +92,7 @@ createParticles() {
94
 
95
  if (!this.started) {
96
  // Handle welcome sequence swipes
97
- if (dx < -60) {
98
  this.nextWelcomeStep();
99
  }
100
  return;
@@ -141,14 +139,14 @@ animateEntrance() {
141
  async fetchRandomArticle() {
142
  try {
143
  // Check if we should show ad
144
- if (this.swipeCount > 0 && this.swipeCount % 3 === 0) {
145
  await this.showAdvertisement();
146
  }
147
 
148
  this.setLoading(true);
149
  this.clearError();
150
- // Show rabbit animation every 3 swipes
151
- if (this.swipeCount % 3 === 0) {
152
  this.showRabbitAnimation();
153
  }
154
  const res = await fetch(
@@ -171,14 +169,14 @@ const res = await fetch(
171
  const next = this.outgoingLinks[Math.floor(Math.random() * this.outgoingLinks.length)];
172
  try {
173
  // Check if we should show ad
174
- if (this.swipeCount > 0 && this.swipeCount % 3 === 0) {
175
  await this.showAdvertisement();
176
  }
177
 
178
  this.setLoading(true);
179
  this.clearError();
180
- // Show rabbit animation every 3 swipes
181
- if (this.swipeCount % 3 === 0) {
182
  this.showRabbitAnimation();
183
  }
184
  const res = await fetch(
@@ -307,7 +305,6 @@ updateProgress() {
307
  this.card.style.display = 'flex';
308
  this.showWelcomeStep(0);
309
  });
310
-
311
  // Force video to play and ensure it ends properly
312
  video.play().catch(() => {
313
  // If video fails to play, use fallback
@@ -315,8 +312,7 @@ updateProgress() {
315
  this.card.style.display = 'flex';
316
  this.showWelcomeStep(0);
317
  });
318
-
319
- // Fallback in case video doesn't fire ended event
320
  setTimeout(() => {
321
  if (rabbitAnimation.style.display !== 'none') {
322
  rabbitAnimation.style.display = 'none';
@@ -362,19 +358,23 @@ showWelcomeStep(stepIndex) {
362
  }, 2000);
363
  }
364
  }
365
- showRabbitAnimation() {
366
  const rabbitAnim = document.getElementById('rabbit-animation');
367
  const video = document.getElementById('rabbit-video');
368
 
369
  rabbitAnim.style.display = 'flex';
370
- video.play();
 
 
 
 
 
371
  // Remove the animation after video completes
372
  video.addEventListener('ended', () => {
373
  rabbitAnim.style.display = 'none';
374
  video.currentTime = 0;
375
  });
376
-
377
- // Fallback timeout in case video doesn't fire ended event
378
  setTimeout(() => {
379
  if (rabbitAnim.style.display !== 'none') {
380
  rabbitAnim.style.display = 'none';
 
52
  }
53
  ];
54
  this.currentStep = 0;
55
+ this.init();
 
56
  }
 
57
  init() {
58
  this.createParticles();
59
  this.bindEvents();
 
92
 
93
  if (!this.started) {
94
  // Handle welcome sequence swipes
95
+ if (Math.abs(dx) > 60) {
96
  this.nextWelcomeStep();
97
  }
98
  return;
 
139
  async fetchRandomArticle() {
140
  try {
141
  // Check if we should show ad
142
+ if (this.swipeCount > 0 && this.swipeCount % 5 === 0) {
143
  await this.showAdvertisement();
144
  }
145
 
146
  this.setLoading(true);
147
  this.clearError();
148
+ // Show rabbit animation every 5 swipes
149
+ if (this.swipeCount % 5 === 0) {
150
  this.showRabbitAnimation();
151
  }
152
  const res = await fetch(
 
169
  const next = this.outgoingLinks[Math.floor(Math.random() * this.outgoingLinks.length)];
170
  try {
171
  // Check if we should show ad
172
+ if (this.swipeCount > 0 && this.swipeCount % 5 === 0) {
173
  await this.showAdvertisement();
174
  }
175
 
176
  this.setLoading(true);
177
  this.clearError();
178
+ // Show rabbit animation every 5 swipes
179
+ if (this.swipeCount % 5 === 0) {
180
  this.showRabbitAnimation();
181
  }
182
  const res = await fetch(
 
305
  this.card.style.display = 'flex';
306
  this.showWelcomeStep(0);
307
  });
 
308
  // Force video to play and ensure it ends properly
309
  video.play().catch(() => {
310
  // If video fails to play, use fallback
 
312
  this.card.style.display = 'flex';
313
  this.showWelcomeStep(0);
314
  });
315
+ // Fallback in case video doesn't fire ended event
 
316
  setTimeout(() => {
317
  if (rabbitAnimation.style.display !== 'none') {
318
  rabbitAnimation.style.display = 'none';
 
358
  }, 2000);
359
  }
360
  }
361
+ showRabbitAnimation() {
362
  const rabbitAnim = document.getElementById('rabbit-animation');
363
  const video = document.getElementById('rabbit-video');
364
 
365
  rabbitAnim.style.display = 'flex';
366
+ video.currentTime = 0;
367
+ video.play().catch(() => {
368
+ // If video fails to play, hide animation immediately
369
+ rabbitAnim.style.display = 'none';
370
+ });
371
+
372
  // Remove the animation after video completes
373
  video.addEventListener('ended', () => {
374
  rabbitAnim.style.display = 'none';
375
  video.currentTime = 0;
376
  });
377
+ // Fallback timeout in case video doesn't fire ended event
 
378
  setTimeout(() => {
379
  if (rabbitAnim.style.display !== 'none') {
380
  rabbitAnim.style.display = 'none';