Skip to content

Commit 9d54c72

Browse files
authored
Update fast-search-card.js
1 parent b8a6cd7 commit 9d54c72

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

dist/fast-search-card.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,7 @@ class FastSearchCard extends HTMLElement {
11461146
}
11471147

11481148

1149+
11491150
.icon-video {
11501151
position: absolute;
11511152
top: 0;
@@ -1154,9 +1155,9 @@ class FastSearchCard extends HTMLElement {
11541155
height: 100%;
11551156
object-fit: cover;
11561157
border-radius: 20px;
1157-
z-index: 2; /* Höher als background */
1158-
opacity: 1; /* Direkt sichtbar */
1159-
background: black; /* Schwarzer Hintergrund während Laden */
1158+
z-index: 2;
1159+
opacity: 0; /* Startet unsichtbar */
1160+
transition: none; /* Keine CSS-Transition, da wir Web Animations nutzen */
11601161
}
11611162

11621163
.icon-video[autoplay] {
@@ -8135,12 +8136,21 @@ class FastSearchCard extends HTMLElement {
81358136

81368137
// Nur bei echter URL-Änderung updaten
81378138
if (newVideoUrl && currentSrc && !currentSrc.includes(newVideoUrl.split('/').pop())) {
8138-
videoElement.src = newVideoUrl;
8139-
videoElement.load();
8140-
8141-
videoElement.onended = function() {
8142-
this.pause();
8143-
this.currentTime = this.duration - 0.1;
8139+
// Fade-out → Update → Fade-in
8140+
videoElement.animate([
8141+
{ opacity: 1 },
8142+
{ opacity: 0 }
8143+
], {
8144+
duration: 300,
8145+
easing: 'ease-out'
8146+
}).onfinish = () => {
8147+
videoElement.src = newVideoUrl;
8148+
videoElement.load();
8149+
8150+
videoElement.onended = function() {
8151+
this.pause();
8152+
this.currentTime = this.duration - 0.1;
8153+
};
81448154
};
81458155
}
81468156
}
@@ -14781,17 +14791,31 @@ class FastSearchCard extends HTMLElement {
1478114791
const videoUrl = this.getVideoUrl(item);
1478214792
if (!videoUrl) return '';
1478314793

14784-
// Eindeutige ID für das Video generieren
1478514794
const videoId = `video-${item.id.replace(/\./g, '-')}`;
1478614795

1478714796
return `
14788-
<video class="icon-video" id="${videoId}" autoplay muted playsinline>
14797+
<video class="icon-video" id="${videoId}" autoplay muted playsinline
14798+
oncanplay="this.parentElement.parentElement.parentElement.fastSearchCard.animateVideoIn(this)">
1478914799
<source src="${videoUrl}" type="video/mp4">
1479014800
<source src="${videoUrl.replace('.mp4', '.webm')}" type="video/webm">
1479114801
</video>
1479214802
`;
1479314803
}
1479414804

14805+
animateVideoIn(videoElement) {
14806+
if (!videoElement) return;
14807+
14808+
// Fade-in Animation mit Web Animations API
14809+
videoElement.animate([
14810+
{ opacity: 0, transform: 'scale(0.95)' },
14811+
{ opacity: 1, transform: 'scale(1)' }
14812+
], {
14813+
duration: 600,
14814+
easing: 'cubic-bezier(0.16, 1, 0.3, 1)',
14815+
fill: 'forwards'
14816+
});
14817+
}
14818+
1479514819

1479614820

1479714821

0 commit comments

Comments
 (0)