animate.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. function createGradioAnimation() {
  2. const params = new URLSearchParams(window.location.search);
  3. if (!params.has('__theme')) {
  4. params.set('__theme', 'light');
  5. window.location.search = params.toString();
  6. }
  7. var gradioApp = document.querySelector('gradio-app');
  8. if (gradioApp) {
  9. document.documentElement.style.setProperty('--my-200', '#80eeee');
  10. document.documentElement.style.setProperty('--my-50', '#ecfdf5');
  11. // gradioApp.style.position = 'relative';
  12. // gradioApp.style.backgroundSize = '200% 200%';
  13. // gradioApp.style.animation = 'moveJellyBackground 10s ease infinite';
  14. // gradioApp.style.backgroundImage = 'radial-gradient(circle at 0% 50%, var(--my-200), var(--my-50) 50%)';
  15. // gradioApp.style.display = 'flex';
  16. // gradioApp.style.justifyContent = 'flex-start';
  17. // gradioApp.style.flexWrap = 'nowrap';
  18. // gradioApp.style.overflowX = 'auto';
  19. // for (let i = 0; i < 6; i++) {
  20. // var quan = document.createElement('div');
  21. // quan.className = 'quan';
  22. // gradioApp.insertBefore(quan, gradioApp.firstChild);
  23. // quan.id = 'quan' + i.toString();
  24. // quan.style.left = 'calc(var(--water-width) * ' + i.toString() + ')';
  25. // var quanContainer = document.querySelector('.quan');
  26. // if (quanContainer) {
  27. // var shui = document.createElement('div');
  28. // shui.className = 'shui';
  29. // quanContainer.insertBefore(shui, quanContainer.firstChild)
  30. // }
  31. // }
  32. }
  33. var container = document.createElement('div');
  34. container.id = 'gradio-animation';
  35. container.style.fontSize = '2em';
  36. container.style.fontFamily = 'Maiandra GD, ui-monospace, monospace';
  37. container.style.fontWeight = 'bold';
  38. container.style.textAlign = 'center';
  39. container.style.marginBottom = '20px';
  40. var text = 'Welcome to Fish-Speech!';
  41. for (var i = 0; i < text.length; i++) {
  42. (function(i){
  43. setTimeout(function(){
  44. var letter = document.createElement('span');
  45. letter.style.opacity = '0';
  46. letter.style.transition = 'opacity 0.5s';
  47. letter.innerText = text[i];
  48. container.appendChild(letter);
  49. setTimeout(function() {
  50. letter.style.opacity = '1';
  51. }, 50);
  52. }, i * 200);
  53. })(i);
  54. }
  55. var gradioContainer = document.querySelector('.gradio-container');
  56. gradioContainer.insertBefore(container, gradioContainer.firstChild);
  57. return 'Animation created';
  58. }