-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
ADDED Cursor Animation of INDIAN TRICOLOR Theme #879
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,21 @@ | |
justify-content: center; | ||
} | ||
</style> | ||
</head> | ||
<style> | ||
/* circle styles */ | ||
.circle { | ||
height: 24px; | ||
width: 24px; | ||
border-radius: 24px; | ||
background-color: rgb(255, 0, 0); | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
pointer-events: none; | ||
z-index: 99999999; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<header> | ||
|
@@ -202,6 +216,76 @@ <h5>How do I download my resume?</h5> | |
}); | ||
}); | ||
</script> | ||
|
||
<!-- Circles --> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
<div class="circle"></div> | ||
Comment on lines
+220
to
+240
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve HTML structure and accessibility The current implementation has several areas for improvement:
Consider this improved approach: -<!-- Circles -->
-<div class="circle"></div>
-<div class="circle"></div>
-... (repeated 18 more times)
+<div id="cursor-trail" aria-hidden="true">
+ <!-- Circles will be generated via JavaScript -->
+</div> Then in your JavaScript: const cursorTrail = document.getElementById('cursor-trail');
const circleCount = 20;
// Respect user's motion preferences
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
for (let i = 0; i < circleCount; i++) {
const circle = document.createElement('div');
circle.className = 'circle';
cursorTrail.appendChild(circle);
}
} |
||
|
||
<script> | ||
// coordinates for the cursor : | ||
const coords = { x: 0, y: 0 }; | ||
const circles = document.querySelectorAll(".circle"); | ||
|
||
const colors = [ | ||
"#fc5720", "#fc6532", "#fc6532","#fd8b65", "#d5585c", "#fac3b1", "#f4d5cb", "#fefefe", "#fefefe", "#cdf2c5", "#b2eca5", "#95e283", "#7dda68", "#4adc2d", "#69d451", "#54c939", "#34b916", "#28b309", "#1e9c02", | ||
]; | ||
|
||
circles.forEach(function (circle, index) { | ||
circle.x = 0; | ||
circle.y = 0; | ||
circle.style.backgroundColor = colors[index % colors.length]; | ||
}); | ||
|
||
// update the coordinates when the mouse moves: | ||
window.addEventListener("mousemove", function (e) { | ||
coords.x = e.clientX; | ||
coords.y = e.clientY; | ||
}); | ||
|
||
// animation function to move the circles: | ||
function animateCircles() { | ||
let x = coords.x; | ||
let y = coords.y; | ||
|
||
circles.forEach(function (circle, index) { | ||
|
||
|
||
circle.style.left = x - 12 + "px"; | ||
circle.style.top = y - 12 + "px"; | ||
circle.style.scale = (circles.length - index) / circles.length; | ||
|
||
circle.x = x; | ||
circle.y = y; | ||
|
||
const nextCircle = circles[index + 1] || circles[0]; | ||
x += (nextCircle.x - x) * 0.3; | ||
y += (nextCircle.y - y) * 0.3; | ||
}); | ||
|
||
requestAnimationFrame(animateCircles); | ||
} | ||
|
||
animateCircles(); | ||
</script> | ||
Comment on lines
+242
to
+287
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve animation implementation and performance Several issues need attention:
Consider these improvements: const colors = [
- "#fc5720", "#fc6532", "#fc6532","#fd8b65", "#d5585c", "#fac3b1", "#f4d5cb", "#fefefe", "#fefefe", "#cdf2c5", "#b2eca5", "#95e283", "#7dda68", "#4adc2d", "#69d451", "#54c939", "#34b916", "#28b309", "#1e9c02",
+ "#FF9933", // Saffron
+ "#FFFFFF", // White
+ "#138808", // Green
];
+let animationFrameId;
+
function animateCircles() {
// ... existing animation code ...
- requestAnimationFrame(animateCircles);
+ animationFrameId = requestAnimationFrame(animateCircles);
}
+// Cleanup on page unload
+window.addEventListener('unload', () => {
+ if (animationFrameId) {
+ cancelAnimationFrame(animationFrameId);
+ }
+});
+// Throttle animation for better performance
+let isThrottled = false;
+window.addEventListener("mousemove", (e) => {
+ if (!isThrottled) {
+ coords.x = e.clientX;
+ coords.y = e.clientY;
+ isThrottled = true;
+ setTimeout(() => isThrottled = false, 16); // ~60fps
+ }
+});
|
||
|
||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,7 +9,7 @@ | |||||||||||||||||
|
||||||||||||||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> | ||||||||||||||||||
<link rel="stylesheet" href="style.css"> | ||||||||||||||||||
</head> | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
<style> | ||||||||||||||||||
:root { | ||||||||||||||||||
|
@@ -388,7 +388,22 @@ | |||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
</style> | ||||||||||||||||||
</head> | ||||||||||||||||||
|
||||||||||||||||||
<style> | ||||||||||||||||||
/* circle styles */ | ||||||||||||||||||
.circle { | ||||||||||||||||||
height: 24px; | ||||||||||||||||||
width: 24px; | ||||||||||||||||||
border-radius: 24px; | ||||||||||||||||||
background-color: rgb(255, 0, 0); | ||||||||||||||||||
position: fixed; | ||||||||||||||||||
top: 0; | ||||||||||||||||||
left: 0; | ||||||||||||||||||
pointer-events: none; | ||||||||||||||||||
z-index: 99999999; | ||||||||||||||||||
} | ||||||||||||||||||
</style> | ||||||||||||||||||
Comment on lines
+393
to
+405
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consolidate '.circle' Class Styles into External Stylesheet The styles for the Add the .circle {
height: 24px;
width: 24px;
border-radius: 24px;
background-color: rgb(255, 0, 0);
position: fixed;
top: 0;
left: 0;
pointer-events: none;
z-index: 99999999;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked by replacing all bunch of recomonded statements but the output changes and not what I need to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PatelHarsh2006, understood. If moving the (_/) ✏️ Learnings added
|
||||||||||||||||||
</head> | ||||||||||||||||||
<body> | ||||||||||||||||||
|
||||||||||||||||||
<div id="progress-container"> | ||||||||||||||||||
|
@@ -542,5 +557,75 @@ <h3>Connect With Us</h3> | |||||||||||||||||
} | ||||||||||||||||||
}); | ||||||||||||||||||
</script> | ||||||||||||||||||
|
||||||||||||||||||
<!-- Circles --> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||
|
||||||||||||||||||
<script> | ||||||||||||||||||
// coordinates for the cursor : | ||||||||||||||||||
const coords = { x: 0, y: 0 }; | ||||||||||||||||||
const circles = document.querySelectorAll(".circle"); | ||||||||||||||||||
|
||||||||||||||||||
const colors = [ | ||||||||||||||||||
"#fc5720", "#fc6532", "#fc6532","#fd8b65", "#d5585c", "#fac3b1", "#f4d5cb", "#fefefe", "#fefefe", "#cdf2c5", "#b2eca5", "#95e283", "#7dda68", "#4adc2d", "#69d451", "#54c939", "#34b916", "#28b309", "#1e9c02", | ||||||||||||||||||
]; | ||||||||||||||||||
Comment on lines
+588
to
+590
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align Circle Colors with the Indian Tricolor Theme The Modify the -const colors = [
- "#fc5720", "#fc6532", "#fc6532","#fd8b65", "#d5585c", "#fac3b1", "#f4d5cb", "#fefefe", "#fefefe", "#cdf2c5", "#b2eca5", "#95e283", "#7dda68", "#4adc2d", "#69d451", "#54c939", "#34b916", "#28b309", "#1e9c02",
-];
+const colors = [
+ "#FF9933", // Saffron
+ "#FFFFFF", // White
+ "#138808", // Green
+]; 📝 Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked by replacing all bunch of recomonded statements but the output changes and not what I need to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PatelHarsh2006, I understand that replacing the colors array as suggested altered the output in a way that doesn't match your desired effect. To maintain the animation while incorporating the Indian tricolor theme, you can create a gradient of colors that smoothly transition between saffron, white, and green. Here's a revised const colors = [
"#FF9933", // Saffron
"#FFA347",
"#FFAD5B",
"#FFB76F",
"#FFC184",
"#FFCB98",
"#FFD5AC",
"#FFE0C0",
"#FFEAD5",
"#FFFFFF", // White
"#D6F5D6",
"#ADEBAD",
"#85E085",
"#5CD65C",
"#33CC33",
"#2EB82E",
"#29A329",
"#248F24",
"#1F7A1F",
"#138808", // Green
]; This array provides a smooth transition between the tricolor colors, which should enhance the visual effect of the animation. Make sure that the number of colors in the array corresponds well with the number of circles for a cohesive appearance. Also, you might want to adjust the number of circles in your HTML to match the length of the <!-- Circles -->
<div class="circle"></div>
<!-- Repeat the above line for as many times as there are colors --> Let me know if this helps or if you'd like further assistance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don,t agree the colors recommonded as they does not give true feeling indian tricolor but what i agrre is the no of circle should match the color array There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PatelHarsh2006, understood. Thank you for explaining your preference. Ensuring that the number of circles matches the length of the (。•́︿•̀。) |
||||||||||||||||||
|
||||||||||||||||||
circles.forEach(function (circle, index) { | ||||||||||||||||||
circle.x = 0; | ||||||||||||||||||
circle.y = 0; | ||||||||||||||||||
circle.style.backgroundColor = colors[index % colors.length]; | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
// update the coordinates when the mouse moves: | ||||||||||||||||||
window.addEventListener("mousemove", function (e) { | ||||||||||||||||||
coords.x = e.clientX; | ||||||||||||||||||
coords.y = e.clientY; | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
// animation function to move the circles: | ||||||||||||||||||
function animateCircles() { | ||||||||||||||||||
let x = coords.x; | ||||||||||||||||||
let y = coords.y; | ||||||||||||||||||
|
||||||||||||||||||
circles.forEach(function (circle, index) { | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
circle.style.left = x - 12 + "px"; | ||||||||||||||||||
circle.style.top = y - 12 + "px"; | ||||||||||||||||||
circle.style.scale = (circles.length - index) / circles.length; | ||||||||||||||||||
|
||||||||||||||||||
circle.x = x; | ||||||||||||||||||
circle.y = y; | ||||||||||||||||||
|
||||||||||||||||||
const nextCircle = circles[index + 1] || circles[0]; | ||||||||||||||||||
x += (nextCircle.x - x) * 0.3; | ||||||||||||||||||
y += (nextCircle.y - y) * 0.3; | ||||||||||||||||||
PatelHarsh2006 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
requestAnimationFrame(animateCircles); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
animateCircles(); | ||||||||||||||||||
</script> | ||||||||||||||||||
|
||||||||||||||||||
</body> | ||||||||||||||||||
</html> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -58,7 +58,21 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
margin-top: 10px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* circle styles */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.circle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
height: 24px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
width: 24px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
border-radius: 24px; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
background-color: rgb(255, 0, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
position: fixed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
top: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
left: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pointer-events: none; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
z-index: 99999999; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+61
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimize circle styles for better maintainability. The CSS styling for circles has several potential issues:
Consider these improvements: .circle {
height: 24px;
width: 24px;
border-radius: 24px;
- background-color: rgb(255, 0, 0);
position: fixed;
top: 0;
left: 0;
pointer-events: none;
- z-index: 99999999;
+ z-index: 9999;
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="heading"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<br><br><br> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -195,5 +209,75 @@ <h1>Resume ATS Score Finder</h1> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<!-- Circles --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div class="circle"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+213
to
+234
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve circle elements implementation. The current implementation has 20 identical div elements that could be optimized:
Consider this approach: - <!-- Circles -->
- <div class="circle"></div>
- <!-- repeated 20 times -->
+ <!-- Cursor Animation Container -->
+ <div id="cursor-animation" aria-hidden="true">
+ <!-- Circles will be generated by JavaScript -->
+ </div> And in your JavaScript: const cursorAnimation = document.getElementById('cursor-animation');
const circleCount = 10; // Reduced number for better performance
for (let i = 0; i < circleCount; i++) {
const circle = document.createElement('div');
circle.className = 'circle';
cursorAnimation.appendChild(circle);
} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// coordinates for the cursor : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const coords = { x: 0, y: 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const circles = document.querySelectorAll(".circle"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const colors = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"#fc5720", "#fc6532", "#fc6532","#fd8b65", "#d5585c", "#fac3b1", "#f4d5cb", "#fefefe", "#fefefe", "#cdf2c5", "#b2eca5", "#95e283", "#7dda68", "#4adc2d", "#69d451", "#54c939", "#34b916", "#28b309", "#1e9c02", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circles.forEach(function (circle, index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circle.x = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circle.y = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circle.style.backgroundColor = colors[index % colors.length]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// update the coordinates when the mouse moves: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
window.addEventListener("mousemove", function (e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coords.x = e.clientX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coords.y = e.clientY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// animation function to move the circles: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
function animateCircles() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let x = coords.x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let y = coords.y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circles.forEach(function (circle, index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circle.style.left = x - 12 + "px"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circle.style.top = y - 12 + "px"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circle.style.scale = (circles.length - index) / circles.length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circle.x = x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
circle.y = y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const nextCircle = circles[index + 1] || circles[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
x += (nextCircle.x - x) * 0.3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
y += (nextCircle.y - y) * 0.3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
requestAnimationFrame(animateCircles); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
animateCircles(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+235
to
+280
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align implementation with Indian tricolor theme and optimize performance. The current implementation has several areas for improvement:
Consider these improvements: const colors = [
- "#fc5720", "#fc6532", "#fc6532","#fd8b65", "#d5585c", "#fac3b1", "#f4d5cb", "#fefefe", "#fefefe", "#cdf2c5", "#b2eca5", "#95e283", "#7dda68", "#4adc2d", "#69d451", "#54c939", "#34b916", "#28b309", "#1e9c02",
+ // Saffron shades
+ "#FF9933", "#FF9933", "#FFA346", "#FFA346",
+ // White shades
+ "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF",
+ // Green shades
+ "#138808", "#138808", "#138808", "#138808"
];
+ // Throttle mousemove events
+ let ticking = false;
window.addEventListener("mousemove", function (e) {
+ if (!ticking) {
+ window.requestAnimationFrame(function() {
coords.x = e.clientX;
coords.y = e.clientY;
+ ticking = false;
+ });
+ ticking = true;
+ }
});
+ // Store animation frame ID for cleanup
+ let animationFrameId;
function animateCircles() {
// ... existing animation code ...
- requestAnimationFrame(animateCircles);
+ animationFrameId = requestAnimationFrame(animateCircles);
}
+ // Cleanup on page unload
+ window.addEventListener('unload', function() {
+ if (animationFrameId) {
+ cancelAnimationFrame(animationFrameId);
+ }
+ }); Also, consider extracting magic numbers into named constants: const CIRCLE_OFFSET = 12; // Replace hardcoded 12 in position calculations
const TRAIL_FACTOR = 0.3; // Replace hardcoded 0.3 in trail effect |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSS styling needs alignment with Indian tricolor theme
The current circle styling has a few concerns:
Consider this improved implementation:
Note: The background-color is removed as it's being set dynamically in JavaScript.