Skip to content

Commit

Permalink
refactor: use animations for appearing and disappearing
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer committed Jul 26, 2024
1 parent 70f815f commit 9d0f41a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
37 changes: 25 additions & 12 deletions assets/chat/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -785,24 +785,15 @@ hr {

.event-bar-button {
cursor: pointer;
transition:
transform 500ms,
opacity 500ms;
opacity: 0;
transform: scale(0.1);

&.active {
transform: unset;
opacity: 1;
}
animation: event-bar-appear 500ms linear;

&:hover {
transition: transform 100ms;
transform: scale(1.05) !important;
transform: scale(1.05);
}

&.removed {
transform: scale(0.1) !important;
animation: event-bar-disappear 500ms linear;
}
}

Expand Down Expand Up @@ -850,6 +841,28 @@ hr {
}
}

@keyframes event-bar-appear {
0% {
transform: scale(0.1);
opacity: 0;
}

100% {
opacity: 1;
}
}

@keyframes event-bar-disappear {
0% {
opacity: 1;
}

100% {
transform: scale(0.1);
opacity: 0;
}
}

@keyframes scrolling-event-username {
25%,
50% {
Expand Down
7 changes: 2 additions & 5 deletions assets/chat/js/menus/ChatEventBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ export default class ChatEventBar {
eventButton.append(eventMessageUI);

this.eventBarUI.prepend(eventButton);
setTimeout(() => {
eventButton.classList.add('active');
}, 1);

// Update chat window to fix the scroll position
this.chat.mainwindow.update();
Expand All @@ -68,11 +65,11 @@ export default class ChatEventBar {
percentageLeft = this.calculateExpiryPercentage(event);

if (percentageLeft <= 0) {
eventButton.addEventListener('transitionend', () => {
eventButton.addEventListener('animationend', () => {
eventButton.remove();
clearInterval(intervalID);
});
eventButton.classList.replace('active', 'removed');
eventButton.classList.add('removed');
return;
}

Expand Down

0 comments on commit 9d0f41a

Please sign in to comment.