Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/content/Components/DecayCard/DecayCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ const DecayCard = ({
}) => {
const svgRef = useRef(null);
const displacementMapRef = useRef(null);
const cursor = useRef({ x: window.innerWidth / 2, y: window.innerHeight / 2 });
const cursor = useRef({
x: typeof window !== 'undefined' ? window.innerWidth / 2 : 0,
y: typeof window !== 'undefined' ? window.innerHeight / 2 : 0
});
const cachedCursor = useRef({ ...cursor.current });
const winsize = useRef({ width: window.innerWidth, height: window.innerHeight });
const winsize = useRef({
width: typeof window !== 'undefined' ? window.innerWidth : 0,
height: typeof window !== 'undefined' ? window.innerHeight : 0
});

useEffect(() => {
const lerp = (a, b, n) => (1 - n) * a + n * b;
Expand Down
5 changes: 4 additions & 1 deletion src/content/Components/Masonry/Masonry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { gsap } from 'gsap';
import './Masonry.css';

const useMedia = (queries, values, defaultValue) => {
const get = () => values[queries.findIndex(q => matchMedia(q).matches)] ?? defaultValue;
const get = () => {
if (typeof window === 'undefined') return defaultValue;
return values[queries.findIndex(q => matchMedia(q).matches)] ?? defaultValue;
};

const [value, setValue] = useState(get);

Expand Down
4 changes: 3 additions & 1 deletion src/content/Components/PixelCard/PixelCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ export default function PixelCard({ variant = 'default', gap, speed, colors, noF
const pixelsRef = useRef([]);
const animationRef = useRef(null);
const timePreviousRef = useRef(performance.now());
const reducedMotion = useRef(window.matchMedia('(prefers-reduced-motion: reduce)').matches).current;
const reducedMotion = useRef(
typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
).current;

const variantCfg = VARIANTS[variant] || VARIANTS.default;
const finalGap = gap ?? variantCfg.gap;
Expand Down
10 changes: 8 additions & 2 deletions src/tailwind/Components/DecayCard/DecayCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ const DecayCard = ({
}) => {
const svgRef = useRef(null);
const displacementMapRef = useRef(null);
const cursor = useRef({ x: window.innerWidth / 2, y: window.innerHeight / 2 });
const cursor = useRef({
x: typeof window !== 'undefined' ? window.innerWidth / 2 : 0,
y: typeof window !== 'undefined' ? window.innerHeight / 2 : 0
});
const cachedCursor = useRef({ ...cursor.current });
const winsize = useRef({ width: window.innerWidth, height: window.innerHeight });
const winsize = useRef({
width: typeof window !== 'undefined' ? window.innerWidth : 0,
height: typeof window !== 'undefined' ? window.innerHeight : 0
});

useEffect(() => {
const lerp = (a, b, n) => (1 - n) * a + n * b;
Expand Down
5 changes: 4 additions & 1 deletion src/tailwind/Components/Masonry/Masonry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
import { gsap } from 'gsap';

const useMedia = (queries, values, defaultValue) => {
const get = () => values[queries.findIndex(q => matchMedia(q).matches)] ?? defaultValue;
const get = () => {
if (typeof window === 'undefined') return defaultValue;
return values[queries.findIndex(q => matchMedia(q).matches)] ?? defaultValue;
};

const [value, setValue] = useState(get);

Expand Down
4 changes: 3 additions & 1 deletion src/tailwind/Components/PixelCard/PixelCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ export default function PixelCard({ variant = 'default', gap, speed, colors, noF
const pixelsRef = useRef([]);
const animationRef = useRef(null);
const timePreviousRef = useRef(performance.now());
const reducedMotion = useRef(window.matchMedia('(prefers-reduced-motion: reduce)').matches).current;
const reducedMotion = useRef(
typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
).current;

const variantCfg = VARIANTS[variant] || VARIANTS.default;
const finalGap = gap ?? variantCfg.gap;
Expand Down
8 changes: 4 additions & 4 deletions src/ts-default/Components/DecayCard/DecayCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const DecayCard: React.FC<DecayCardProps> = ({
const svgRef = useRef<HTMLDivElement>(null);
const displacementMapRef = useRef<SVGFEDisplacementMapElement>(null);
const cursor = useRef<{ x: number; y: number }>({
x: window.innerWidth / 2,
y: window.innerHeight / 2
x: typeof window !== 'undefined' ? window.innerWidth / 2 : 0,
y: typeof window !== 'undefined' ? window.innerHeight / 2 : 0
});
const cachedCursor = useRef<{ x: number; y: number }>({ ...cursor.current });
const winsize = useRef<{ width: number; height: number }>({
width: window.innerWidth,
height: window.innerHeight
width: typeof window !== 'undefined' ? window.innerWidth : 0,
height: typeof window !== 'undefined' ? window.innerHeight : 0
});

useEffect(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/ts-default/Components/Masonry/Masonry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { gsap } from 'gsap';
import './Masonry.css';

const useMedia = (queries: string[], values: number[], defaultValue: number): number => {
const get = () => values[queries.findIndex(q => matchMedia(q).matches)] ?? defaultValue;
const get = () => {
if (typeof window === 'undefined') return defaultValue;
return values[queries.findIndex(q => matchMedia(q).matches)] ?? defaultValue;
};

const [value, setValue] = useState<number>(get);

Expand Down
4 changes: 3 additions & 1 deletion src/ts-default/Components/PixelCard/PixelCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ export default function PixelCard({
const pixelsRef = useRef<Pixel[]>([]);
const animationRef = useRef<ReturnType<typeof requestAnimationFrame> | null>(null);
const timePreviousRef = useRef(performance.now());
const reducedMotion = useRef(window.matchMedia('(prefers-reduced-motion: reduce)').matches).current;
const reducedMotion = useRef(
typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
).current;

const variantCfg: VariantConfig = VARIANTS[variant] || VARIANTS.default;
const finalGap = gap ?? variantCfg.gap;
Expand Down
8 changes: 4 additions & 4 deletions src/ts-tailwind/Components/DecayCard/DecayCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const DecayCard: React.FC<DecayCardProps> = ({
const svgRef = useRef<HTMLDivElement | null>(null);
const displacementMapRef = useRef<SVGFEDisplacementMapElement | null>(null);
const cursor = useRef<{ x: number; y: number }>({
x: window.innerWidth / 2,
y: window.innerHeight / 2
x: typeof window !== 'undefined' ? window.innerWidth / 2 : 0,
y: typeof window !== 'undefined' ? window.innerHeight / 2 : 0
});
const cachedCursor = useRef<{ x: number; y: number }>({ ...cursor.current });
const winsize = useRef<{ width: number; height: number }>({
width: window.innerWidth,
height: window.innerHeight
width: typeof window !== 'undefined' ? window.innerWidth : 0,
height: typeof window !== 'undefined' ? window.innerHeight : 0
});

useEffect(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/ts-tailwind/Components/Masonry/Masonry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 're
import { gsap } from 'gsap';

const useMedia = (queries: string[], values: number[], defaultValue: number): number => {
const get = () => values[queries.findIndex(q => matchMedia(q).matches)] ?? defaultValue;
const get = () => {
if (typeof window === 'undefined') return defaultValue;
return values[queries.findIndex(q => matchMedia(q).matches)] ?? defaultValue;
};

const [value, setValue] = useState<number>(get);

Expand Down
4 changes: 3 additions & 1 deletion src/ts-tailwind/Components/PixelCard/PixelCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ export default function PixelCard({
const pixelsRef = useRef<Pixel[]>([]);
const animationRef = useRef<ReturnType<typeof requestAnimationFrame> | null>(null);
const timePreviousRef = useRef(performance.now());
const reducedMotion = useRef(window.matchMedia('(prefers-reduced-motion: reduce)').matches).current;
const reducedMotion = useRef(
typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
).current;

const variantCfg: VariantConfig = VARIANTS[variant] || VARIANTS.default;
const finalGap = gap ?? variantCfg.gap;
Expand Down