Remove advertisement banners from the hero section in index.html, adjust formatting of ad links for consistency, and add a new script for cat animations. Update JavaScript component loading syntax for improved readability.
This commit is contained in:
31
index.html
31
index.html
@@ -29,18 +29,6 @@
|
||||
<main>
|
||||
<!-- Hero Section -->
|
||||
<section id="hero"></section>
|
||||
<aside class="hero-ad">
|
||||
<div class="vertical-ad-banner">
|
||||
<div class="ad-content">
|
||||
<div class="ad-icon">
|
||||
<i class="bi bi-rocket-takeoff"></i>
|
||||
</div>
|
||||
<h4>Company</h4>
|
||||
<p>Transform Your Business with Our Solutions</p>
|
||||
<a href="#" class="ad-link">Explore Now <i class="bi bi-arrow-right"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- About Section -->
|
||||
<section id="about"></section>
|
||||
@@ -54,7 +42,9 @@
|
||||
<h4>Boost Your Growth</h4>
|
||||
<p>Partner with Company for Digital Excellence</p>
|
||||
</div>
|
||||
<a href="#" class="ad-link">Get Started <i class="bi bi-arrow-right"></i></a>
|
||||
<a href="#" class="ad-link"
|
||||
>Get Started <i class="bi bi-arrow-right"></i
|
||||
></a>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -69,7 +59,9 @@
|
||||
</div>
|
||||
<h4>Secure Solutions</h4>
|
||||
<p>Trusted by Industry Leaders</p>
|
||||
<a href="#" class="ad-link">Learn More <i class="bi bi-arrow-right"></i></a>
|
||||
<a href="#" class="ad-link"
|
||||
>Learn More <i class="bi bi-arrow-right"></i
|
||||
></a>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -86,7 +78,9 @@
|
||||
<h4>Fast Development</h4>
|
||||
<p>Accelerate Your Project Timeline</p>
|
||||
</div>
|
||||
<a href="#" class="ad-link">Start Now <i class="bi bi-arrow-right"></i></a>
|
||||
<a href="#" class="ad-link"
|
||||
>Start Now <i class="bi bi-arrow-right"></i
|
||||
></a>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -101,7 +95,9 @@
|
||||
</div>
|
||||
<h4>Premium Services</h4>
|
||||
<p>Expert Solutions for Your Business</p>
|
||||
<a href="#" class="ad-link">Discover More <i class="bi bi-arrow-right"></i></a>
|
||||
<a href="#" class="ad-link"
|
||||
>Discover More <i class="bi bi-arrow-right"></i
|
||||
></a>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -121,6 +117,7 @@
|
||||
<script src="js/jquery.magnific-popup.min.js"></script>
|
||||
<script src="js/magnific-popup-options.js"></script>
|
||||
<script src="js/custom.js"></script>
|
||||
<script src="js/cat-animation.js"></script>
|
||||
|
||||
<!-- Load Components -->
|
||||
<script>
|
||||
@@ -133,7 +130,7 @@
|
||||
services: "components/services.html",
|
||||
projects: "components/projects.html",
|
||||
contact: "components/contact.html",
|
||||
footer: "components/footer.html"
|
||||
footer: "components/footer.html",
|
||||
};
|
||||
|
||||
// Load all components
|
||||
|
||||
281
js/cat-animation.js
Normal file
281
js/cat-animation.js
Normal file
@@ -0,0 +1,281 @@
|
||||
class Cat {
|
||||
constructor(canvas, x, y, scale = 1, color = 'default') {
|
||||
this.canvas = canvas;
|
||||
this.ctx = canvas.getContext('2d');
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.scale = scale;
|
||||
this.color = color;
|
||||
this.direction = 1;
|
||||
this.speed = 2;
|
||||
this.frame = 0;
|
||||
this.frameCount = 8;
|
||||
this.frameWidth = 64;
|
||||
this.frameHeight = 64;
|
||||
this.isPaused = false;
|
||||
this.pauseTimer = 0;
|
||||
this.pauseDuration = 0;
|
||||
this.pawPrints = [];
|
||||
this.lastPawPrint = 0;
|
||||
this.lastMeow = 0;
|
||||
this.meowCooldown = 3000; // 3 seconds between meows
|
||||
|
||||
// Initialize sounds with error handling
|
||||
this.sounds = {
|
||||
meow: null,
|
||||
purr: null,
|
||||
paw: null
|
||||
};
|
||||
|
||||
// Create audio elements with error handling
|
||||
try {
|
||||
this.sounds.meow = new Audio('sounds/meow.wav');
|
||||
this.sounds.paw = new Audio('sounds/paw.wav');
|
||||
|
||||
// Set volume for each sound
|
||||
this.sounds.meow.volume = 0.4;
|
||||
this.sounds.purr.volume = 0.3;
|
||||
this.sounds.paw.volume = 0.2;
|
||||
|
||||
// Add error handling for each sound
|
||||
Object.entries(this.sounds).forEach(([key, sound]) => {
|
||||
if (sound) {
|
||||
sound.addEventListener('error', (e) => {
|
||||
console.warn(`Error loading ${key} sound:`, e);
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Error initializing sounds:', error);
|
||||
}
|
||||
}
|
||||
|
||||
playSound(soundName) {
|
||||
try {
|
||||
const sound = this.sounds[soundName];
|
||||
if (sound) {
|
||||
sound.currentTime = 0;
|
||||
sound.play().catch(error => {
|
||||
console.warn(`Error playing ${soundName} sound:`, error);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Error playing ${soundName} sound:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
update() {
|
||||
if (this.isPaused) {
|
||||
this.pauseTimer++;
|
||||
if (this.pauseTimer >= this.pauseDuration) {
|
||||
this.isPaused = false;
|
||||
this.pauseTimer = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Random pause and meow
|
||||
if (Math.random() < 0.005) {
|
||||
this.isPaused = true;
|
||||
this.pauseDuration = Math.random() * 100 + 100;
|
||||
|
||||
// Random meow during pause
|
||||
if (Date.now() - this.lastMeow > this.meowCooldown) {
|
||||
this.playSound('meow');
|
||||
this.lastMeow = Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
// Update position
|
||||
this.x += this.speed * this.direction;
|
||||
|
||||
// Change direction at edges
|
||||
if (this.x >= this.canvas.width - this.frameWidth * this.scale) {
|
||||
this.direction = -1;
|
||||
this.playSound('paw');
|
||||
} else if (this.x <= 0) {
|
||||
this.direction = 1;
|
||||
this.playSound('paw');
|
||||
}
|
||||
|
||||
// Update animation frame
|
||||
this.frame = (this.frame + 0.2) % this.frameCount;
|
||||
|
||||
// Add paw prints with sound
|
||||
if (Date.now() - this.lastPawPrint > 200) {
|
||||
this.addPawPrint();
|
||||
this.lastPawPrint = Date.now();
|
||||
// Play paw sound occasionally
|
||||
if (Math.random() < 0.3) {
|
||||
this.playSound('paw');
|
||||
}
|
||||
}
|
||||
|
||||
// Update paw prints
|
||||
this.pawPrints = this.pawPrints.filter(print => {
|
||||
print.opacity -= 0.02;
|
||||
return print.opacity > 0;
|
||||
});
|
||||
}
|
||||
|
||||
draw() {
|
||||
// Draw paw prints
|
||||
this.pawPrints.forEach(print => {
|
||||
this.ctx.globalAlpha = print.opacity;
|
||||
this.ctx.fillStyle = '#000';
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(print.x, print.y, 3, 0, Math.PI * 2);
|
||||
this.ctx.fill();
|
||||
});
|
||||
this.ctx.globalAlpha = 1;
|
||||
|
||||
// Draw cat
|
||||
this.ctx.save();
|
||||
this.ctx.translate(this.x, this.y);
|
||||
this.ctx.scale(this.direction * this.scale, this.scale);
|
||||
|
||||
// Draw cat body
|
||||
this.ctx.fillStyle = this.color === 'default' ? '#666' :
|
||||
this.color === 'orange' ? '#FFA500' : '#000';
|
||||
|
||||
// Body
|
||||
this.ctx.beginPath();
|
||||
this.ctx.ellipse(32, 40, 20, 15, 0, 0, Math.PI * 2);
|
||||
this.ctx.fill();
|
||||
|
||||
// Head
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(15, 35, 12, 0, Math.PI * 2);
|
||||
this.ctx.fill();
|
||||
|
||||
// Ears
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(8, 28);
|
||||
this.ctx.lineTo(5, 20);
|
||||
this.ctx.lineTo(12, 28);
|
||||
this.ctx.fill();
|
||||
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(22, 28);
|
||||
this.ctx.lineTo(25, 20);
|
||||
this.ctx.lineTo(18, 28);
|
||||
this.ctx.fill();
|
||||
|
||||
// Tail
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(52, 40);
|
||||
this.ctx.quadraticCurveTo(60, 30, 65, 40);
|
||||
this.ctx.strokeStyle = this.ctx.fillStyle;
|
||||
this.ctx.lineWidth = 4;
|
||||
this.ctx.stroke();
|
||||
|
||||
// Legs (animated)
|
||||
const legOffset = Math.sin(this.frame * 0.5) * 5;
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(25, 55);
|
||||
this.ctx.lineTo(25, 55 + legOffset);
|
||||
this.ctx.moveTo(35, 55);
|
||||
this.ctx.lineTo(35, 55 - legOffset);
|
||||
this.ctx.moveTo(45, 55);
|
||||
this.ctx.lineTo(45, 55 + legOffset);
|
||||
this.ctx.strokeStyle = this.ctx.fillStyle;
|
||||
this.ctx.lineWidth = 3;
|
||||
this.ctx.stroke();
|
||||
|
||||
this.ctx.restore();
|
||||
}
|
||||
|
||||
addPawPrint() {
|
||||
const offset = this.direction === 1 ? 20 : -20;
|
||||
this.pawPrints.push({
|
||||
x: this.x + offset,
|
||||
y: this.y + this.frameHeight * this.scale - 5,
|
||||
opacity: 0.5
|
||||
});
|
||||
}
|
||||
|
||||
isPointInside(x, y) {
|
||||
return x >= this.x &&
|
||||
x <= this.x + this.frameWidth * this.scale &&
|
||||
y >= this.y &&
|
||||
y <= this.y + this.frameHeight * this.scale;
|
||||
}
|
||||
|
||||
interact(x, y) {
|
||||
if (this.isPointInside(x, y)) {
|
||||
this.isPaused = true;
|
||||
this.pauseDuration = 100;
|
||||
|
||||
// Play purr sound when petted
|
||||
this.playSound('purr');
|
||||
|
||||
// Occasionally meow when petted
|
||||
if (Math.random() < 0.3 && Date.now() - this.lastMeow > this.meowCooldown) {
|
||||
this.playSound('meow');
|
||||
this.lastMeow = Date.now();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize cat animation
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const container = document.createElement('div');
|
||||
container.id = 'cat-container';
|
||||
container.style.cssText = `
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
pointer-events: none;
|
||||
z-index: 9999;
|
||||
`;
|
||||
document.body.appendChild(container);
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = 100;
|
||||
container.appendChild(canvas);
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
const cats = [
|
||||
new Cat(canvas, 0, 20, 1, 'default'),
|
||||
new Cat(canvas, 200, 10, 0.8, 'orange'),
|
||||
new Cat(canvas, 400, 30, 1.2, 'black')
|
||||
];
|
||||
|
||||
// Handle window resize
|
||||
window.addEventListener('resize', () => {
|
||||
canvas.width = window.innerWidth;
|
||||
});
|
||||
|
||||
// Handle mouse interaction
|
||||
canvas.style.pointerEvents = 'auto';
|
||||
canvas.addEventListener('click', (e) => {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left;
|
||||
const y = e.clientY - rect.top;
|
||||
|
||||
cats.forEach(cat => {
|
||||
cat.interact(x, y);
|
||||
});
|
||||
});
|
||||
|
||||
// Animation loop
|
||||
function animate() {
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
cats.forEach(cat => {
|
||||
cat.update();
|
||||
cat.draw();
|
||||
});
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
});
|
||||
BIN
sounds/meow.wav
Normal file
BIN
sounds/meow.wav
Normal file
Binary file not shown.
1
sounds/paw.mp3
Normal file
1
sounds/paw.mp3
Normal file
@@ -0,0 +1 @@
|
||||
404: Not Found
|
||||
BIN
sounds/paw.wav
Normal file
BIN
sounds/paw.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user