Skip to content

Commit

Permalink
animation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
arkajyotiadhikary committed Nov 24, 2024
1 parent 9aad60a commit aad8308
Showing 1 changed file with 7 additions and 24 deletions.
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

0 comments on commit aad8308

Please sign in to comment.