OzoneAsai commited on
Commit
2a49bbd
·
verified ·
1 Parent(s): 90775d8

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +17 -3
templates/index.html CHANGED
@@ -44,10 +44,24 @@
44
 
45
  function navigate(url) {
46
  const flashcard = document.getElementById('flashcard');
47
- flashcard.classList.add('fade-out');
48
- setTimeout(function() {
49
  window.location.href = url;
50
- }, 500); // Match this duration with the CSS animation duration
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
52
  </script>
53
  </body>
 
44
 
45
  function navigate(url) {
46
  const flashcard = document.getElementById('flashcard');
47
+ animateFadeOut(flashcard, function() {
 
48
  window.location.href = url;
49
+ });
50
+ }
51
+
52
+ function animateFadeOut(element, callback) {
53
+ let opacity = 1;
54
+ function fade() {
55
+ opacity -= 0.1;
56
+ if (opacity <= 0) {
57
+ element.style.opacity = 0;
58
+ callback();
59
+ } else {
60
+ element.style.opacity = opacity;
61
+ requestAnimationFrame(fade);
62
+ }
63
+ }
64
+ fade();
65
  }
66
  </script>
67
  </body>