Skip to content

Commit 1758d47

Browse files
committed
Refactor timeline shift logic for negative lastStamp
1 parent 885cfbd commit 1758d47

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Protest/Front/view.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -829,12 +829,15 @@ class View extends Window {
829829
this.timeline.onmouseenter = ()=> { this.floating.style.display = "initial"; };
830830
this.timeline.onmouseleave = ()=> { this.floating.style.display = "none"; };
831831

832-
//TODO: need a better way
833-
if (lastStamp < 0 && maxGap.length > 3) {
834-
let diff = Math.abs(lastStamp);
835-
if (diff > maxGap) diff = maxGap - 2;
836-
for (let i = maxGap.index; i < sorted.length; i++) {
837-
sorted[i].con.style.left = `calc(${sorted[i].x + diff}% - 5px)`;
832+
if (lastStamp < 0 && maxGap.index >= 0) {
833+
const availableShift = Math.max(0, maxGap.length - 2);
834+
const diff = Math.min(Math.abs(lastStamp), availableShift);
835+
836+
if (diff > 0) {
837+
for (let i = maxGap.index; i < sorted.length; i++) {
838+
sorted[i].x += diff;
839+
sorted[i].con.style.left = `calc(${sorted[i].x}% - 5px)`;
840+
}
838841
}
839842
}
840843
}
@@ -1027,4 +1030,4 @@ class View extends Window {
10271030
Copy() {} //overridable
10281031

10291032
Delete() {} //overridable
1030-
}
1033+
}

0 commit comments

Comments
 (0)