This commit is contained in:
Harvey Zack committed 2022-05-01 15:02:30 +08:00
1 parent 8087a93534
commit 632e88ae0b
4 files changed
+53 -23

No files matched your search

@@ -1,5 +1,6 @@
export default function getDanmuTop(ins, danmu) {
const { clientWidth, clientHeight } = ins.$player;
const { marginBottom, marginTop } = ins;
const { antiOverlap } = ins.option;
const danmus = ins.queue
@@ -8,38 +9,52 @@ export default function getDanmuTop(ins, danmu) {
item.$ref &&
item.$state === 'emit' &&
item.mode === danmu.mode &&
item.$ref.offsetTop <= clientHeight - ins.marginBottom
item.$ref.offsetTop <= clientHeight - marginBottom
);
})
.map((item) => {
const top = item.$ref.offsetTop;
const left = item.$ref.offsetLeft;
const height = item.$ref.clientHeight;
const width = item.$ref.clientWidth;
const distance = left + width;
const right = clientWidth - distance;
const speed = distance / item.$restTime;
return {
top: item.$ref.offsetTop,
left: item.$ref.offsetLeft,
height: item.$ref.clientHeight,
width: item.$ref.clientWidth,
right: clientWidth - item.$ref.offsetLeft - item.$ref.clientWidth,
top,
left,
height,
width,
right,
speed,
distance,
};
})
.sort((prev, next) => prev.top - next.top);
if (danmus.length === 0) {
return ins.marginTop;
return marginTop;
}
danmus.unshift({
top: 0,
left: 0,
right: 0,
height: ins.marginTop,
height: marginTop,
width: clientWidth,
speed: 0,
distance: clientWidth,
});
danmus.push({
top: clientHeight - ins.marginBottom,
top: clientHeight - marginBottom,
left: 0,
right: 0,
height: ins.marginBottom,
height: marginBottom,
width: clientWidth,
speed: 0,
distance: clientWidth,
});
for (let index = 1; index < danmus.length; index += 1) {