Skip to content

Commit

Permalink
refactor: Move peer icon highlight removal before delta animation
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Dec 11, 2024
1 parent 28842e8 commit 21c5bc5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions hugo-site/layouts/shortcodes/summary-delta-sync/sync.html
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,15 @@
// Force reflow
container.offsetHeight;

// Remove highlights from peer icons before starting delta animation
document.querySelectorAll('.peer-icons i').forEach(icon => {
icon.style.boxShadow = '';
icon.style.color = '';
icon.style.backgroundColor = '';
icon.style.borderRadius = '';
icon.style.transition = 'all 0.3s ease-in-out';
});

// Make deltas visible and animate them to their destinations
requestAnimationFrame(() => {
if (peerState.peer1.delta.length > 0) {
Expand All @@ -626,16 +635,8 @@
}, 100);
}

// Remove highlights from previous step and add missing icons
// Add missing icons
setTimeout(() => {
// Remove highlights from peer icons
document.querySelectorAll('.peer-icons i').forEach(icon => {
icon.style.boxShadow = '';
icon.style.color = '';
icon.style.backgroundColor = '';
icon.style.borderRadius = '';
icon.style.transition = 'all 0.3s ease-in-out';
});
peerState.peer1.icons = [...new Set([...peerState.peer1.icons, ...peerState.peer2.delta])];
peerState.peer2.icons = [...new Set([...peerState.peer2.icons, ...peerState.peer1.delta])];

Expand Down

0 comments on commit 21c5bc5

Please sign in to comment.