Skip to content

Commit fa8b64b

Browse files
authored
Update fast-search-card.js
1 parent 77a81e5 commit fa8b64b

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

dist/fast-search-card.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,10 @@ class FastSearchCard extends HTMLElement {
595595
}
596596

597597
.clear-button.visible {
598-
display: flex;
599-
opacity: 1;
600-
}
598+
display: flex !important;
599+
opacity: 1 !important;
600+
transform: scale(1) !important;
601+
}
601602

602603
.clear-button:hover {
603604
background: rgba(0, 0, 0, 0.25);
@@ -4280,13 +4281,24 @@ class FastSearchCard extends HTMLElement {
42804281
const searchInput = this.shadowRoot.querySelector('.search-input');
42814282
this.isSearching = query.trim().length > 0;
42824283
if (this.searchTimeout) { clearTimeout(this.searchTimeout); }
4284+
42834285
if (query.length > 0) {
4284-
clearButton.classList.add('visible');
4285-
this.animateElementIn(clearButton, { scale: [0, 1], opacity: [0, 1] });
4286+
if (!clearButton.classList.contains('visible')) {
4287+
clearButton.classList.add('visible');
4288+
clearButton.offsetHeight; // Force reflow
4289+
this.animateElementIn(clearButton, { scale: [0, 1], opacity: [0, 1] });
4290+
}
42864291
} else {
42874292
this.isSearching = false;
4288-
const animation = this.animateElementOut(clearButton);
4289-
animation.finished.then(() => { clearButton.classList.remove('visible'); });
4293+
4294+
if (clearButton.classList.contains('visible')) {
4295+
const animation = this.animateElementOut(clearButton);
4296+
animation.finished.then(() => {
4297+
clearButton.classList.remove('visible');
4298+
clearButton.style.transform = '';
4299+
clearButton.style.scale = '';
4300+
});
4301+
}
42904302
}
42914303
searchInput.animate([{ transform: 'scale(1)' }, { transform: 'scale(1.02)' }, { transform: 'scale(1)' }], { duration: 200, easing: 'ease-out' });
42924304
if (!this.isPanelExpanded) { this.expandPanel(); }
@@ -12991,6 +13003,12 @@ class FastSearchCard extends HTMLElement {
1299113003

1299213004
animateElementIn(element, keyframes, options = {}) {
1299313005
if (!element) return;
13006+
13007+
// Reset alle Transform-Properties vor Animation
13008+
element.style.transform = '';
13009+
element.style.scale = '';
13010+
element.style.opacity = '';
13011+
1299413012
return element.animate(keyframes, {
1299513013
duration: 400,
1299613014
easing: 'cubic-bezier(0.16, 1, 0.3, 1)',

0 commit comments

Comments
 (0)