forked from AnujShrivastava01/AnimateItNow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplates.js
More file actions
154 lines (125 loc) Β· 5.27 KB
/
templates.js
File metadata and controls
154 lines (125 loc) Β· 5.27 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// π¦ Template-Specific Functionality Handler
// Theme management and cursor logic are delegated to script.js
// π Search & Category Filter System
const searchInput = document.getElementById("search-bar");
const templateCardElements = document.querySelectorAll(".template-card");
const noResultsMessage = document.querySelector(".no-results");
const filterToggleButton = document.getElementById("filter-toggle");
const categoryFilterContainer = document.getElementById("category-filters");
const categoryButtonElements = document.querySelectorAll(".category-btn");
// π― Currently selected category filter
let currentActiveCategory = "all";
// π Toggle category filter dropdown visibility
filterToggleButton.addEventListener("click", (event) => {
event.stopPropagation();
categoryFilterContainer.classList.toggle("show");
});
// πͺ Close category filters when user clicks outside the container
document.addEventListener("click", (event) => {
if (!filterToggleButton.contains(event.target) && !categoryFilterContainer.contains(event.target)) {
categoryFilterContainer.classList.remove("show");
}
});
// π Category filtering implementation
categoryButtonElements.forEach(button => {
button.addEventListener("click", () => {
// Update active button state
categoryButtonElements.forEach(btn => btn.classList.remove("active"));
button.classList.add("active");
// Set current active category
currentActiveCategory = button.dataset.category;
// Apply template filtering
applyTemplateFiltering();
// Collapse dropdown after selection
categoryFilterContainer.classList.remove("show");
});
});
// π Search and filter functionality
function applyTemplateFiltering() {
const searchQuery = searchInput.value.trim().toLowerCase();
let visibleTemplateCount = 0;
templateCardElements.forEach((cardElement) => {
const cardTitle = cardElement.querySelector("h2").textContent.trim().toLowerCase();
const cardCategory = cardElement.dataset.category;
// Verify if card matches search criteria
const matchesSearchQuery = searchQuery === "" || cardTitle.includes(searchQuery);
// Verify if card matches category filter
const matchesCategoryFilter = currentActiveCategory === "all" || cardCategory === currentActiveCategory;
// Display logic based on filter conditions
if (matchesSearchQuery && matchesCategoryFilter) {
cardElement.style.display = "";
visibleTemplateCount++;
} else {
cardElement.style.display = "none";
}
});
// Handle no results message visibility
if (noResultsMessage) {
noResultsMessage.style.display = visibleTemplateCount === 0 ? "block" : "none";
}
}
// π±οΈ Add input event listener to search bar
searchInput.addEventListener("input", applyTemplateFiltering);
// π Initialize template filtering on page load
applyTemplateFiltering();
// π¬ Text Animation Handler for Sequential Display
const animationTexts = [
"Typing Animation",
"Gradient Text",
"Neon Glow",
"Wavy Text Animation",
"Zoom on Hover",
];
let currentTextIndex = 0; // Current position in text array
let currentCharIndex = 0; // Current character position for typing/deleting
let isDeletingMode = false;
const animationSpeed = 100; // Character typing/deletion speed
const pauseDuration = 1000; // Pause between animations
const animationTarget = document.getElementById("textTarget");
// π§ Development debugging utility
function logDebugInfo(message) {
// π Placeholder for potential debugging requirements
// console.log(`[Template System] ${message}`);
}
if (animationTarget) {
// π Main animation loop for text effects
function executeTypeAnimation() {
const currentAnimationText = animationTexts[currentTextIndex];
if (isDeletingMode) {
animationTarget.textContent = currentAnimationText.substring(0, currentCharIndex--);
} else {
animationTarget.textContent = currentAnimationText.substring(0, currentCharIndex++);
}
// Completed typing full text
if (!isDeletingMode && currentCharIndex === currentAnimationText.length + 1) {
setTimeout(() => {
isDeletingMode = true;
executeTypeAnimation();
}, pauseDuration);
return;
}
// Transition to next text after deletion
if (isDeletingMode && currentCharIndex === 0) {
isDeletingMode = false;
// Use modulo for circular array navigation
currentTextIndex = (currentTextIndex + 1) % animationTexts.length;
}
// Deletion occurs at faster rate than typing
setTimeout(executeTypeAnimation, isDeletingMode ? animationSpeed / 2 : animationSpeed);
}
executeTypeAnimation(); // Initialize animation sequence
}
// π§ͺ Performance monitoring placeholder function
function trackPerformanceMetrics() {
// π Reserved for future performance monitoring implementation
// console.log("Performance metrics collection:", performance.memory);
}
// π§Ό Resource cleanup and memory management
function performCleanupOperations() {
// π§Ή Reserved for future cleanup and optimization tasks
console.log("π§Ή Template system cleanup operations completed");
}
// π Additional utility function for future enhancements
function initializeTemplateSystem() {
console.log("π― Template filtering system initialized successfully");
}