Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

border animations #4044

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
animation issue
  • Loading branch information
arkajyotiadhikary committed Nov 24, 2024
commit aad83088ce231e6e14dc8ebc289c84b76f6b2858
31 changes: 7 additions & 24 deletions src/common/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ class Card {
const decorations = [];
const spacing = this.width / 6;

// Same positioning logic
// Ensure decorations are within the viewBox
const positions = [
{ x: spacing, y: -decorSize / 2 },
{ x: this.width - spacing, y: -decorSize / 2 },
{ x: -decorSize / 2, y: this.height / 3 },
{ x: -decorSize / 2, y: (this.height / 3) * 2 },
{ x: spacing, y: decorSize / 2 },
{ x: this.width - spacing, y: decorSize / 2 },
{ x: decorSize / 2, y: this.height / 3 },
{ x: decorSize / 2, y: (this.height / 3) * 2 },
{ x: this.width - decorSize / 2, y: this.height / 3 },
{ x: this.width - decorSize / 2, y: (this.height / 3) * 2 },
{ x: spacing, y: this.height - decorSize / 2 },
Expand All @@ -198,8 +198,8 @@ class Card {

positions.forEach((pos) => {
const shapeType = _.random(0, 3); // 0: hexagon, 1: circle, 2: square, 3: triangle
const opacity = _.random(0.3, 0.7);
const strokeWidth = _.random(0.5, 2);
const opacity = _.random(0.5, 0.9); // Ensure higher opacity for visibility
const strokeWidth = _.random(1, 2);
const rotation = _.random(0, 360);

let shape = "";
Expand Down Expand Up @@ -267,28 +267,11 @@ class Card {
break;
}

// Randomly add connecting lines
const hasLine = _.random(0, 1) === 1;
const line = hasLine
? `
<line
x1="${decorSize / 2}"
y1="${decorSize / 2}"
x2="${decorSize}"
y2="${decorSize / 2}"
stroke="${this.colors.titleColor}"
stroke-width="${strokeWidth / 2}"
opacity="${opacity}"
/>
`
: "";

decorations.push(`
<g transform="translate(${pos.x}, ${pos.y}) rotate(${rotation}, ${decorSize / 2}, ${decorSize / 2})"
class="decoration"
style="--tx:${pos.x}px; --ty:${pos.y}px;">
${shape}
${line}
</g>
`);
});
Expand Down