diff --git a/package.json b/package.json index 11d8430..800e66c 100644 --- a/package.json +++ b/package.json @@ -29,14 +29,13 @@ "prettier-plugin-tailwindcss": "^0.6.11", "svelte": "^5.0.0", "svelte-check": "^4.0.0", - "svelte-hero-icons": "^5.2.0", "tailwindcss": "^4.0.0", "typescript": "^5.0.0", "typescript-eslint": "^8.20.0", "vite": "^6.2.5" }, "dependencies": { - "@tarekraafat/autocomplete.js": "^10.2.9", - "moment": "^2.30.1" + "moment": "^2.30.1", + "svelte-hero-icons": "^5.2.0" } } diff --git a/src/lib/HeardleGame.svelte b/src/lib/HeardleGame.svelte index 1d6a86c..d25d9ea 100644 --- a/src/lib/HeardleGame.svelte +++ b/src/lib/HeardleGame.svelte @@ -232,23 +232,21 @@ countdownInterval = setInterval(updateTime, 1000); widget = SC.Widget(iframeElement); - // wait for full page load (or you could just use setTimeout) - window.addEventListener('load', () => { - widget.bind(SC.Widget.Events.READY, () => { - widget.getDuration((d: number) => (fullDuration = d)); - widget.getCurrentSound((sound: any) => { - artworkUrl = sound.artwork_url || ''; - }); - - // give SC widget 2s to settle on Netlify before probing - setTimeout(() => { - widget.play(); - widget.pause(); - widget.seekTo(0); - loading = false; - widgetReady = true; - }, 2000); + widget.bind(SC.Widget.Events.READY, () => { + // grab duration & artwork + widget.getDuration((d: number) => (fullDuration = d)); + widget.getCurrentSound((sound: any) => { + artworkUrl = sound.artwork_url || ''; }); + + // small delay for Netlify, then probe the player + setTimeout(() => { + widget.play(); + widget.pause(); + widget.seekTo(0); + loading = false; + widgetReady = true; + }, 1000); }); widget.bind(SC.Widget.Events.PLAY, () => {