update getDanmuTop

This commit is contained in:
Harvey Zack committed 2022-04-30 17:31:41 +08:00
1 parent 8ea10853ad
commit def8c6df46
3 files changed
+41 -13

No files matched your search

@@ -26,11 +26,24 @@ function calculatedTop(danmus, danmu) {
}
}
topMap.sort((prev, next) => {
const nextMinRight = Math.min(...next.map((item) => item.right));
const prevMinRight = Math.min(...prev.map((item) => item.right));
return nextMinRight * next.length - prevMinRight * prev.length;
});
switch (danmu.mode) {
case 0:
topMap.sort((prev, next) => {
const nextMinRight = Math.min(...next.map((item) => item.right));
const prevMinRight = Math.min(...prev.map((item) => item.right));
return nextMinRight * next.length - prevMinRight * prev.length;
});
break;
case 1:
topMap.sort((prev, next) => {
const nextMaxWidth = Math.max(...next.map((item) => item.width));
const prevMaxWidth = Math.max(...prev.map((item) => item.width));
return prevMaxWidth * prev.length - nextMaxWidth * next.length;
});
break;
default:
break;
}
return topMap[0][0].top;
}