animate.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. }