Skip to content
Open
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
2 changes: 1 addition & 1 deletion public/r/ElectricBorder-JS-CSS.json

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/r/ElectricBorder-TS-CSS.json

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/content/Animations/ElectricBorder/ElectricBorder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,23 @@ const ElectricBorder = ({
};

let { width, height } = updateSize();
let lastDpr = Math.min(window.devicePixelRatio || 1, 2);

const drawElectricBorder = currentTime => {
if (!canvas || !ctx) return;

const dpr = Math.min(window.devicePixelRatio || 1, 2);
if (dpr !== lastDpr) {
lastDpr = dpr;
const newSize = updateSize();
width = newSize.width;
height = newSize.height;
}

const deltaTime = (currentTime - lastFrameTimeRef.current) / 1000;
timeRef.current += deltaTime * speed;
lastFrameTimeRef.current = currentTime;

// Clear canvas
const dpr = Math.min(window.devicePixelRatio || 1, 2);
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.scale(dpr, dpr);
Expand Down
10 changes: 9 additions & 1 deletion src/tailwind/Animations/ElectricBorder/ElectricBorder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,23 @@ const ElectricBorder = ({
};

let { width, height } = updateSize();
let lastDpr = Math.min(window.devicePixelRatio || 1, 2);

const drawElectricBorder = currentTime => {
if (!canvas || !ctx) return;

const dpr = Math.min(window.devicePixelRatio || 1, 2);
if (dpr !== lastDpr) {
lastDpr = dpr;
const newSize = updateSize();
width = newSize.width;
height = newSize.height;
}

const deltaTime = (currentTime - lastFrameTimeRef.current) / 1000;
timeRef.current += deltaTime * speed;
lastFrameTimeRef.current = currentTime;

const dpr = Math.min(window.devicePixelRatio || 1, 2);
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.scale(dpr, dpr);
Expand Down
10 changes: 9 additions & 1 deletion src/ts-default/Animations/ElectricBorder/ElectricBorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,23 @@ const ElectricBorder: React.FC<ElectricBorderProps> = ({
};

let { width, height } = updateSize();
let lastDpr = Math.min(window.devicePixelRatio || 1, 2);

const drawElectricBorder = (currentTime: number) => {
if (!canvas || !ctx) return;

const dpr = Math.min(window.devicePixelRatio || 1, 2);
if (dpr !== lastDpr) {
lastDpr = dpr;
const newSize = updateSize();
width = newSize.width;
height = newSize.height;
}

const deltaTime = (currentTime - lastFrameTimeRef.current) / 1000;
timeRef.current += deltaTime * speed;
lastFrameTimeRef.current = currentTime;

const dpr = Math.min(window.devicePixelRatio || 1, 2);
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.scale(dpr, dpr);
Expand Down
10 changes: 9 additions & 1 deletion src/ts-tailwind/Animations/ElectricBorder/ElectricBorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,23 @@ const ElectricBorder: React.FC<ElectricBorderProps> = ({
};

let { width, height } = updateSize();
let lastDpr = Math.min(window.devicePixelRatio || 1, 2);

const drawElectricBorder = (currentTime: number) => {
if (!canvas || !ctx) return;

const dpr = Math.min(window.devicePixelRatio || 1, 2);
if (dpr !== lastDpr) {
lastDpr = dpr;
const newSize = updateSize();
width = newSize.width;
height = newSize.height;
}

const deltaTime = (currentTime - lastFrameTimeRef.current) / 1000;
timeRef.current += deltaTime * speed;
lastFrameTimeRef.current = currentTime;

const dpr = Math.min(window.devicePixelRatio || 1, 2);
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.scale(dpr, dpr);
Expand Down