Skip to content

Instantly share code, notes, and snippets.

@Slakinov
Slakinov / GoogleAnalytics.svelte
Created November 23, 2022 14:00
Instant Google Analytics for SvelteKit, add to +layout.svelte
<script>
import { page } from '$app/stores';
import { browser } from '$app/environment';
import { onMount } from 'svelte';
export let id;
onMount(() => {
window.dataLayer = window.dataLayer || [];
window.gtag = function() { window.dataLayer.push(arguments) }
@Slakinov
Slakinov / fritz.js
Last active August 11, 2023 00:49
Garbage text animation transition for Svelte as seen on MusicForProgramming.net
export default function(
node,
{
duration = 1000,
delay = 0,
reverse = false,
absolute = false,
pointerEvents = true,
}
) {
@Slakinov
Slakinov / noise.svelte
Last active November 3, 2023 03:54
Svelte Noise Texture Overlay
<script>
import { onMount } from 'svelte';
let canvas, vw, vh, ctx, timer;
onMount(() => {
ctx = canvas.getContext('2d');
vw = window.innerWidth;
vh = window.innerHeight;
canvas.width = vw;
canvas.height = vh;