-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathribbons.js
More file actions
78 lines (66 loc) · 2.03 KB
/
ribbons.js
File metadata and controls
78 lines (66 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Simple CSS-based ribbons effect (no external dependencies)
let initialized = false;
const DEFAULT_OPTIONS = {
colors: ['#ffffff'],
baseThickness: 30,
speedMultiplier: 0.5,
maxAge: 500,
enableFade: false,
enableShaderEffect: true
};
export async function initRibbons(options = {}) {
if (initialized) return;
const container = document.querySelector('.ribbons-layer');
if (!container) {
console.warn('Ribbons container not found');
return;
}
const config = { ...DEFAULT_OPTIONS, ...options };
// Create simple CSS-based ribbons
const ribbonCount = Math.min(config.colors.length, 3); // Limit to 3 ribbons
for (let i = 0; i < ribbonCount; i++) {
const ribbon = document.createElement('div');
ribbon.className = 'simple-ribbon';
ribbon.style.cssText = `
position: absolute;
width: 100%;
height: 2px;
background: linear-gradient(90deg, transparent, ${config.colors[i] || '#ffffff'}, transparent);
opacity: 0.6;
animation: ribbonMove ${2 + i}s linear infinite;
animation-delay: ${i * 0.5}s;
top: ${20 + i * 15}%;
left: 0;
`;
container.appendChild(ribbon);
}
// Add CSS animation if not already added
if (!document.getElementById('ribbons-styles')) {
const style = document.createElement('style');
style.id = 'ribbons-styles';
style.textContent = `
@keyframes ribbonMove {
0% { transform: translateX(-100%) rotate(0deg); }
50% { transform: translateX(50vw) rotate(180deg); }
100% { transform: translateX(100vw) rotate(360deg); }
}
.simple-ribbon {
pointer-events: none;
}
`;
document.head.appendChild(style);
}
initialized = true;
console.log('Simple ribbons effect initialized');
}
export function destroyRibbons() {
const container = document.querySelector('.ribbons-layer');
if (container) {
container.innerHTML = '';
}
const style = document.getElementById('ribbons-styles');
if (style) {
style.remove();
}
initialized = false;
}