Skip to content

Commit c528ff6

Browse files
fix: opacity flicker
1 parent 7ab605a commit c528ff6

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

src/features/Overview/ShredsProgression/shreds.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
background-color: #080b13;
66
border-radius: 2px;
77
border: 1px solid #3c4652;
8-
will-change: transform, width;
8+
will-change: transform;
99
transform: translate(var(--group-x));
1010

1111
&.you {
@@ -42,7 +42,7 @@
4242
--slot-x: 0;
4343

4444
position: absolute;
45-
will-change: transform, width;
45+
will-change: transform;
4646
transform: translate(var(--slot-x));
4747

4848
height: 100%;

src/features/Overview/ShredsProgression/shredsProgressionPlugin.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -662,35 +662,43 @@ function getGroupTsDeltas(
662662
},
663663
groupLeaderSlots: number[],
664664
) {
665-
const groupTsDeltas: {
665+
const tsDeltasByGroup: {
666666
[leaderSlotNumber: number]: TsDeltaRange;
667667
} = {};
668668

669669
for (const leaderSlot of groupLeaderSlots) {
670-
const slotNumbers = Array.from(
671-
{ length: slotsPerLeader },
672-
(_, i) => i + leaderSlot,
670+
const fullGroupTsDeltas = Array.from({ length: slotsPerLeader }, (_, i) => {
671+
const slotNumber = i + leaderSlot;
672+
return slotTsDeltas[slotNumber];
673+
});
674+
675+
const firstDefinedSlotIdx = fullGroupTsDeltas.findIndex(
676+
(v) => v !== undefined,
673677
);
674-
const definedSlotTsDeltas = slotNumbers
675-
.map((slotNumber) => slotTsDeltas[slotNumber])
676-
.filter((v) => v !== undefined);
677678

678-
if (definedSlotTsDeltas.length === 0) {
679-
continue;
680-
}
679+
// no slots, no group
680+
if (firstDefinedSlotIdx === -1) continue;
681+
682+
// ignore missing slots at the start when positioning group.
683+
// handles the case where some we sometimes miss early slot completion events,
684+
// depending on the connection timing
685+
const groupTsDeltas = fullGroupTsDeltas.slice(firstDefinedSlotIdx);
686+
687+
const minStart = Math.min(
688+
...groupTsDeltas.filter((v) => v !== undefined).map(([start]) => start),
689+
);
681690

682-
// ignore missing slots at the start when positioning group
683-
const minStart = Math.min(...definedSlotTsDeltas.map(([start]) => start));
684-
const ends = definedSlotTsDeltas.map(([, end]) => end);
685-
const definedEnds = ends.filter((end) => end !== undefined);
691+
const definedEnds = groupTsDeltas
692+
.map((pos) => pos?.[1] ?? undefined)
693+
.filter((end) => end !== undefined);
686694

687695
// undefined slot end will extend to max x
688-
const hasUndefinedEnd = ends.length > definedEnds.length;
696+
const hasUndefinedEnd = definedEnds.length < groupTsDeltas.length;
689697
const maxEnd = hasUndefinedEnd ? undefined : Math.max(...definedEnds);
690698

691-
groupTsDeltas[leaderSlot] = [minStart, maxEnd];
699+
tsDeltasByGroup[leaderSlot] = [minStart, maxEnd];
692700
}
693-
return groupTsDeltas;
701+
return tsDeltasByGroup;
694702
}
695703

696704
/**

0 commit comments

Comments
 (0)