Personal Site
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace oddbird polyfill with my own, shitter polyfill except it works consistently*

*might break in weird edge cases but it recalcs on viewport or container scroll, window resize, and when the popup opens or closes

vielle.dev 96c85459 5ef4f0c2

verified
+38 -21
+38 -21
src/components/home/playing/NowPlaying.astro
··· 241 241 content: var(--right-arrow-png) / ""; 242 242 position: sticky; 243 243 right: 0px; 244 - 244 + 245 245 padding-inline: 5px; 246 246 height: 100%; 247 247 width: 40px; ··· 400 400 } 401 401 402 402 now-playing { 403 - inset: unset; 404 - position: absolute; 405 - left: anchor(--player left); 406 - bottom: calc(anchor(--player top) + 5cqh); 403 + left: var(--player-left, anchor(--player left)); 404 + bottom: calc(var(--player-top, anchor(--player top)) + 20px); 405 + top: unset; 406 + right: unset; 407 407 text-align: left; 408 408 font-size: 1rem; 409 409 ··· 434 434 435 435 import { isNowPlaying, type nowPlaying } from "./spotify/client"; 436 436 437 - if (!CSS.supports("top", "calc(anchor(--player bottom) + 10px)")) { 438 - // enable anchor polyfill 439 - const { default: anchor } = await import( 440 - "@oddbird/css-anchor-positioning/fn" 441 - ); 442 - 443 - anchor().then(() => 444 - document 445 - .querySelectorAll(".no-anchor-warning") 446 - .forEach((el) => 447 - el instanceof HTMLElement 448 - ? el.style.setProperty("display", "none") 449 - : null, 450 - ), 451 - ); 452 - } 453 437 /************* 454 438 * FUNCTIONS * 455 439 *************/ ··· 802 786 prev = data; 803 787 } 804 788 }); 789 + 790 + /********** 791 + * ANCHOR * 792 + **********/ 793 + 794 + const position = () => { 795 + // recalculate anchor positions 796 + elements.nowPlaying.style.setProperty( 797 + "--player-left", 798 + elements.player.getBoundingClientRect().left + "px", 799 + ); 800 + elements.nowPlaying.style.setProperty( 801 + "--player-top", 802 + window.innerHeight - elements.player.getBoundingClientRect().top + "px", 803 + ); 804 + }; 805 + 806 + if (!CSS.supports("top", "calc(anchor(--player bottom) + 10px)")) { 807 + position(); 808 + elements.nowPlaying.addEventListener("beforetoggle", position); 809 + window.addEventListener("scroll", position); 810 + elements.player.parentNode?.addEventListener("scroll", position); 811 + new ResizeObserver(position).observe(document.documentElement); 812 + } 813 + 814 + // hide the warning element 815 + document 816 + .querySelectorAll(".no-anchor-warning") 817 + .forEach((el) => 818 + el instanceof HTMLElement 819 + ? el.style.setProperty("display", "none") 820 + : null, 821 + ); 805 822 </script>