Skip to content

Commit 271801a

Browse files
authored
Update fast-search-card.js
1 parent 67267e7 commit 271801a

File tree

1 file changed

+75
-16
lines changed

1 file changed

+75
-16
lines changed

dist/fast-search-card.js

Lines changed: 75 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5030,7 +5030,7 @@ class FastSearchCard extends HTMLElement {
50305030
return window.innerWidth <= 768;
50315031
}
50325032

5033-
showCategoryButtons() {
5033+
async showCategoryButtons() {
50345034
this.collapsePanel();
50355035

50365036
if (this.isMobile()) {
@@ -5041,12 +5041,53 @@ class FastSearchCard extends HTMLElement {
50415041
}
50425042

50435043
this.isMenuView = true;
5044-
5045-
// 🌊 NEUE SPOTLIGHT ANIMATION statt alter Animation
5046-
this.startSpotlightAnimation();
5044+
5045+
// --- NEUE, ELEGANTE SPOTLIGHT ANIMATION ---
5046+
const categoryButtonsContainer = this.shadowRoot.querySelector('.category-buttons');
5047+
const buttons = Array.from(categoryButtonsContainer.querySelectorAll('.category-button'));
5048+
5049+
// 1. Vorbereitung: Container und Buttons für Animation vorbereiten
5050+
categoryButtonsContainer.classList.add('visible'); // Container sichtbar machen
5051+
categoryButtonsContainer.style.filter = 'url(#categoryGooey)'; // Gooey-Filter aktivieren
5052+
5053+
// Alle Buttons am Anfang des Containers positionieren und unsichtbar machen
5054+
buttons.forEach(btn => {
5055+
btn.style.transform = 'translateX(0px) scale(0)';
5056+
btn.style.opacity = '0';
5057+
});
5058+
5059+
// 2. Der "Wurm" wächst: Container auf volle Breite animieren
5060+
const containerWidth = buttons.length * 72 + (buttons.length - 1) * 12; // 72px pro Button + 12px Abstand
5061+
const containerAnimation = categoryButtonsContainer.animate([
5062+
{ width: '72px' },
5063+
{ width: `${containerWidth}px` }
5064+
], {
5065+
duration: 400,
5066+
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
5067+
fill: 'forwards'
5068+
});
5069+
await containerAnimation.finished;
5070+
5071+
// 3. Die "Teilung": Buttons zu ihren finalen Positionen animieren
5072+
const animations = buttons.map((btn, index) => {
5073+
const finalX = index * (72 + 12); // Finale X-Position
5074+
return btn.animate([
5075+
{ transform: 'translateX(0px) scale(1)', opacity: 1 },
5076+
{ transform: `translateX(${finalX}px) scale(1)`, opacity: 1 }
5077+
], {
5078+
duration: 600,
5079+
delay: index * 60, // Gestaffelter Start für flüssigen Effekt
5080+
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
5081+
fill: 'forwards'
5082+
});
5083+
});
5084+
await Promise.all(animations.map(a => a.finished));
5085+
5086+
// 4. Aufräumen: Filter entfernen, damit Buttons scharf werden
5087+
categoryButtonsContainer.style.filter = 'none';
50475088
}
50485089

5049-
hideCategoryButtons() {
5090+
async hideCategoryButtons() {
50505091
// NEU: Search-Wrapper wieder anzeigen
50515092
if (this.isMobile()) {
50525093
const searchWrapper = this.shadowRoot.querySelector('.search-panel');
@@ -5055,21 +5096,39 @@ class FastSearchCard extends HTMLElement {
50555096
}
50565097
}
50575098

5058-
const categoryButtons = this.shadowRoot.querySelector('.category-buttons');
5099+
const categoryButtonsContainer = this.shadowRoot.querySelector('.category-buttons');
50595100
if (!this.isMenuView) return;
50605101

5061-
// ZURÜCK ZUR ALTEN ANIMATION
5062-
const animation = categoryButtons.animate([
5063-
{ opacity: 1, transform: 'translateX(0) scale(1)' },
5064-
{ opacity: 0, transform: 'translateX(20px) scale(0.9)' }
5065-
], {
5066-
duration: 300,
5067-
easing: 'ease-in',
5068-
fill: 'forwards'
5102+
const buttons = Array.from(categoryButtonsContainer.querySelectorAll('.category-button'));
5103+
5104+
// Reverse Animation: Buttons zurück zum Startpunkt
5105+
categoryButtonsContainer.style.filter = 'url(#categoryGooey)'; // Filter wieder aktivieren
5106+
5107+
const animations = buttons.map((btn, index) => {
5108+
return btn.animate([
5109+
{ transform: `translateX(${index * (72 + 12)}px) scale(1)`, opacity: 1 },
5110+
{ transform: 'translateX(0px) scale(0)', opacity: 0 }
5111+
], {
5112+
duration: 300,
5113+
delay: (buttons.length - index - 1) * 50, // Rückwärts gestaffelt
5114+
easing: 'ease-in',
5115+
fill: 'forwards'
5116+
});
50695117
});
50705118

5071-
animation.finished.then(() => {
5072-
categoryButtons.classList.remove('visible');
5119+
await Promise.all(animations.map(a => a.finished));
5120+
5121+
// Container zusammenziehen
5122+
categoryButtonsContainer.animate([
5123+
{ width: `${buttons.length * 72 + (buttons.length - 1) * 12}px` },
5124+
{ width: '72px' }
5125+
], {
5126+
duration: 200,
5127+
easing: 'ease-in',
5128+
fill: 'forwards'
5129+
}).finished.then(() => {
5130+
categoryButtonsContainer.classList.remove('visible');
5131+
categoryButtonsContainer.style.filter = 'none';
50735132
this.isMenuView = false;
50745133
});
50755134
}

0 commit comments

Comments
 (0)