This commit is contained in:
Harvey Zack committed 2022-05-01 15:02:30 +08:00
1 parent 99dce8c673
commit 235b235245
3 files changed
+75 -86

No files matched your search

@@ -554,8 +554,35 @@ exports.export = function(dest, destName, get) {
},{}],"eLxSm":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
function calculatedTop(danmus, danmu) {
// 方法1:两两对比,只要找到间隔能塞进一条弹幕的高度的,则马上插入
function getDanmuTop(ins, danmu) {
const { $player } = ins.art.template;
const danmus = ins.queue.filter((item)=>{
return item.$ref && item.$state === 'emit' && item.mode === danmu.mode && item.$ref.offsetTop <= $player.clientHeight - ins.marginBottom;
}).map((item)=>{
return {
top: item.$ref.offsetTop,
left: item.$ref.offsetLeft,
height: item.$ref.clientHeight,
width: item.$ref.clientWidth,
right: $player.clientWidth - item.$ref.offsetLeft - item.$ref.clientWidth
};
}).sort((prev, next)=>prev.top - next.top
);
if (danmus.length === 0) return ins.marginTop;
danmus.unshift({
top: 0,
left: 0,
right: 0,
height: ins.marginTop,
width: $player.clientWidth
});
danmus.push({
top: $player.clientHeight - ins.marginBottom,
left: 0,
right: 0,
height: ins.marginBottom,
width: $player.clientWidth
});
for(let index = 1; index < danmus.length; index += 1){
const item = danmus[index];
const prev = danmus[index - 1];
@@ -563,7 +590,6 @@ function calculatedTop(danmus, danmu) {
const diff = item.top - prevBottom;
if (diff >= danmu.$ref.clientHeight) return prevBottom;
}
// 方法2:找出所有弹幕的右侧最多空白的的位置插入
const topMap = [];
for(let index1 = 1; index1 < danmus.length - 1; index1 += 1){
const item = danmus[index1];
@@ -601,37 +627,6 @@ function calculatedTop(danmus, danmu) {
}
return topMap[0][0].top;
}
function getDanmuTop(ins, danmu) {
const { $player } = ins.art.template;
const danmus = ins.queue.filter((item)=>{
return item.$ref && item.$state === 'emit' && item.mode === danmu.mode && item.$ref.offsetTop <= $player.clientHeight - ins.marginBottom;
}).map((item)=>{
return {
top: item.$ref.offsetTop,
left: item.$ref.offsetLeft,
height: item.$ref.clientHeight,
width: item.$ref.clientWidth,
right: $player.clientWidth - item.$ref.offsetLeft - item.$ref.clientWidth
};
}).sort((prev, next)=>prev.top - next.top
);
if (danmus.length === 0) return ins.marginTop;
danmus.unshift({
top: 0,
left: 0,
right: 0,
height: ins.marginTop,
width: $player.clientWidth
});
danmus.push({
top: $player.clientHeight - ins.marginBottom,
left: 0,
right: 0,
height: ins.marginBottom,
width: $player.clientWidth
});
return calculatedTop(danmus, danmu);
}
exports.default = getDanmuTop;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"6SDkN"}]},["gEVO5"], "gEVO5", "parcelRequire93cf")