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
4 changes: 2 additions & 2 deletions public/r/OrbitImages-JS-CSS.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/r/OrbitImages-JS-TW.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/r/OrbitImages-TS-CSS.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/r/OrbitImages-TS-TW.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/content/Animations/OrbitImages/OrbitImages.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Component created by Dominik Koch
// https://x.com/dominikkoch

import { useMemo, useEffect, useRef, useState } from 'react';
import { useMemo, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { motion, useMotionValue, useTransform, animate } from 'motion/react';
import './OrbitImages.css';

Expand Down Expand Up @@ -124,7 +124,7 @@ export default function OrbitImages({
responsive = false,
}) {
const containerRef = useRef(null);
const [scale, setScale] = useState(1);
const [scale, setScale] = useState(null);

const designCenterX = baseWidth / 2;
const designCenterY = baseWidth / 2;
Expand Down Expand Up @@ -156,7 +156,7 @@ export default function OrbitImages({
}
}, [shape, customPath, designCenterX, designCenterY, radiusX, radiusY, radius, starPoints, starInnerRatio]);

useEffect(() => {
useLayoutEffect(() => {
if (!responsive || !containerRef.current) return;
const updateScale = () => {
if (!containerRef.current) return;
Expand Down Expand Up @@ -210,7 +210,8 @@ export default function OrbitImages({
style={{
width: responsive ? baseWidth : '100%',
height: responsive ? baseWidth : '100%',
transform: responsive ? `translate(-50%, -50%) scale(${scale})` : undefined,
transform: responsive && scale !== null ? `translate(-50%, -50%) scale(${scale})` : undefined,
visibility: responsive && scale === null ? 'hidden' : undefined,
}}
>
<div
Expand All @@ -224,7 +225,7 @@ export default function OrbitImages({
viewBox={`0 0 ${baseWidth} ${baseWidth}`}
className="orbit-path-svg"
>
<path d={path} fill="none" stroke={pathColor} strokeWidth={pathWidth / scale} />
<path d={path} fill="none" stroke={pathColor} strokeWidth={pathWidth / (scale ?? 1)} />
</svg>
)}

Expand Down
11 changes: 6 additions & 5 deletions src/tailwind/Animations/OrbitImages/OrbitImages.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Component created by Dominik Koch
// https://x.com/dominikkoch

import { useMemo, useEffect, useRef, useState } from 'react';
import { useMemo, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { motion, useMotionValue, useTransform, animate } from 'motion/react';

function generateEllipsePath(cx, cy, rx, ry) {
Expand Down Expand Up @@ -123,7 +123,7 @@ export default function OrbitImages({
responsive = false,
}) {
const containerRef = useRef(null);
const [scale, setScale] = useState(1);
const [scale, setScale] = useState(null);

const designCenterX = baseWidth / 2;
const designCenterY = baseWidth / 2;
Expand Down Expand Up @@ -155,7 +155,7 @@ export default function OrbitImages({
}
}, [shape, customPath, designCenterX, designCenterY, radiusX, radiusY, radius, starPoints, starInnerRatio]);

useEffect(() => {
useLayoutEffect(() => {
if (!responsive || !containerRef.current) return;
const updateScale = () => {
if (!containerRef.current) return;
Expand Down Expand Up @@ -209,7 +209,8 @@ export default function OrbitImages({
style={{
width: responsive ? baseWidth : '100%',
height: responsive ? baseWidth : '100%',
transform: responsive ? `translate(-50%, -50%) scale(${scale})` : undefined,
transform: responsive && scale !== null ? `translate(-50%, -50%) scale(${scale})` : undefined,
visibility: responsive && scale === null ? 'hidden' : undefined,
transformOrigin: 'center center',
}}
>
Expand All @@ -227,7 +228,7 @@ export default function OrbitImages({
viewBox={`0 0 ${baseWidth} ${baseWidth}`}
className="absolute inset-0 pointer-events-none"
>
<path d={path} fill="none" stroke={pathColor} strokeWidth={pathWidth / scale} />
<path d={path} fill="none" stroke={pathColor} strokeWidth={pathWidth / (scale ?? 1)} />
</svg>
)}

Expand Down
11 changes: 6 additions & 5 deletions src/ts-default/Animations/OrbitImages/OrbitImages.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Component created by Dominik Koch
// https://x.com/dominikkoch

import { useMemo, useEffect, useRef, useState, ReactNode } from 'react';
import { useMemo, useEffect, useLayoutEffect, useRef, useState, ReactNode } from 'react';
import { motion, useMotionValue, useTransform, animate, MotionValue } from 'motion/react';
import './OrbitImages.css';

Expand Down Expand Up @@ -175,7 +175,7 @@ export default function OrbitImages({
responsive = false,
}: OrbitImagesProps) {
const containerRef = useRef<HTMLDivElement>(null);
const [scale, setScale] = useState(1);
const [scale, setScale] = useState<number | null>(null);

const designCenterX = baseWidth / 2;
const designCenterY = baseWidth / 2;
Expand Down Expand Up @@ -207,7 +207,7 @@ export default function OrbitImages({
}
}, [shape, customPath, designCenterX, designCenterY, radiusX, radiusY, radius, starPoints, starInnerRatio]);

useEffect(() => {
useLayoutEffect(() => {
if (!responsive || !containerRef.current) return;
const updateScale = () => {
if (!containerRef.current) return;
Expand Down Expand Up @@ -261,7 +261,8 @@ export default function OrbitImages({
style={{
width: responsive ? baseWidth : '100%',
height: responsive ? baseWidth : '100%',
transform: responsive ? `translate(-50%, -50%) scale(${scale})` : undefined,
transform: responsive && scale !== null ? `translate(-50%, -50%) scale(${scale})` : undefined,
visibility: responsive && scale === null ? 'hidden' : undefined,
}}
>
<div
Expand All @@ -275,7 +276,7 @@ export default function OrbitImages({
viewBox={`0 0 ${baseWidth} ${baseWidth}`}
className="orbit-path-svg"
>
<path d={path} fill="none" stroke={pathColor} strokeWidth={pathWidth / scale} />
<path d={path} fill="none" stroke={pathColor} strokeWidth={pathWidth / (scale ?? 1)} />
</svg>
)}

Expand Down
11 changes: 6 additions & 5 deletions src/ts-tailwind/Animations/OrbitImages/OrbitImages.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Component created by Dominik Koch
// https://x.com/dominikkoch

import { useMemo, useEffect, useRef, useState, ReactNode } from 'react';
import { useMemo, useEffect, useLayoutEffect, useRef, useState, ReactNode } from 'react';
import { motion, useMotionValue, useTransform, animate, MotionValue } from 'motion/react';

type OrbitShape =
Expand Down Expand Up @@ -174,7 +174,7 @@ export default function OrbitImages({
responsive = false,
}: OrbitImagesProps) {
const containerRef = useRef<HTMLDivElement>(null);
const [scale, setScale] = useState(1);
const [scale, setScale] = useState<number | null>(null);

const designCenterX = baseWidth / 2;
const designCenterY = baseWidth / 2;
Expand Down Expand Up @@ -206,7 +206,7 @@ export default function OrbitImages({
}
}, [shape, customPath, designCenterX, designCenterY, radiusX, radiusY, radius, starPoints, starInnerRatio]);

useEffect(() => {
useLayoutEffect(() => {
if (!responsive || !containerRef.current) return;
const updateScale = () => {
if (!containerRef.current) return;
Expand Down Expand Up @@ -260,7 +260,8 @@ export default function OrbitImages({
style={{
width: responsive ? baseWidth : '100%',
height: responsive ? baseWidth : '100%',
transform: responsive ? `translate(-50%, -50%) scale(${scale})` : undefined,
transform: responsive && scale !== null ? `translate(-50%, -50%) scale(${scale})` : undefined,
visibility: responsive && scale === null ? 'hidden' : undefined,
transformOrigin: 'center center',
}}
>
Expand All @@ -278,7 +279,7 @@ export default function OrbitImages({
viewBox={`0 0 ${baseWidth} ${baseWidth}`}
className="absolute inset-0 pointer-events-none"
>
<path d={path} fill="none" stroke={pathColor} strokeWidth={pathWidth / scale} />
<path d={path} fill="none" stroke={pathColor} strokeWidth={pathWidth / (scale ?? 1)} />
</svg>
)}

Expand Down