mirror of
https://github.com/Matewoo/better-agent-frontend.git
synced 2026-11-18 13:52:49 +01:00
add small attention seeking animation
This commit is contained in:
+46
-2
@@ -218,8 +218,8 @@
|
|||||||
|
|
||||||
// Animation für Fenstervergrößerung UND PADDING
|
// Animation für Fenstervergrößerung UND PADDING
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
chatWindow.style.width = '300px';
|
chatWindow.style.width = '25em';
|
||||||
chatWindow.style.height = '400px';
|
chatWindow.style.height = '30em';
|
||||||
chatWindow.style.borderRadius = '8px';
|
chatWindow.style.borderRadius = '8px';
|
||||||
headerContainer.style.padding = '10px'; // Padding animieren!
|
headerContainer.style.padding = '10px'; // Padding animieren!
|
||||||
|
|
||||||
@@ -231,6 +231,32 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.body.appendChild(button);
|
||||||
|
|
||||||
|
// Add attention animation after 5 seconds
|
||||||
|
setTimeout(() => {
|
||||||
|
// Only animate if the chat window isn't already open
|
||||||
|
if (!document.querySelector('.chat-window')) {
|
||||||
|
// Store original opacity to restore it later if needed
|
||||||
|
const originalOpacity = button.style.opacity;
|
||||||
|
|
||||||
|
// Make button visible for animation
|
||||||
|
button.style.opacity = '1';
|
||||||
|
button.classList.add('chat-widget-attention');
|
||||||
|
|
||||||
|
// Remove animation class after it completes
|
||||||
|
button.addEventListener('animationend', () => {
|
||||||
|
button.classList.remove('chat-widget-attention');
|
||||||
|
|
||||||
|
// Restore original state if user didn't interact
|
||||||
|
if (!document.querySelector('.chat-window')) {
|
||||||
|
// Let normal visibility rules take over again
|
||||||
|
syncScrollTopState();
|
||||||
|
}
|
||||||
|
}, { once: true });
|
||||||
|
}
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
// Synchronize with existing scroll-top button, but use our own classes
|
// Synchronize with existing scroll-top button, but use our own classes
|
||||||
function syncScrollTopState() {
|
function syncScrollTopState() {
|
||||||
// Find the existing scroll-top button
|
// Find the existing scroll-top button
|
||||||
@@ -289,6 +315,24 @@
|
|||||||
opacity: 1 !important;
|
opacity: 1 !important;
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes attentionAnimation {
|
||||||
|
0% { transform: scale(1) rotate(0deg); }
|
||||||
|
10% { transform: scale(1.4) rotate(-10deg); }
|
||||||
|
20% { transform: scale(1.4) rotate(10deg); }
|
||||||
|
30% { transform: scale(1.4) rotate(-10deg); }
|
||||||
|
40% { transform: scale(1.4) rotate(10deg); }
|
||||||
|
50% { transform: scale(1.4) rotate(-8deg); }
|
||||||
|
60% { transform: scale(1.4) rotate(8deg); }
|
||||||
|
70% { transform: scale(1.4) rotate(-5deg); }
|
||||||
|
80% { transform: scale(1.4) rotate(5deg); }
|
||||||
|
90% { transform: scale(1.4) rotate(0deg); }
|
||||||
|
100% { transform: scale(1) rotate(0deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-widget-attention {
|
||||||
|
animation: attentionAnimation 2s ease-in-out;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
document.head.appendChild(styleElement);
|
document.head.appendChild(styleElement);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user