mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-21 04:31:20 -08:00
update danmuku demo
This commit is contained in:
1 parent
9cefead73e
commit
8ea10853ad
6 files changed
+16
-16
No files matched your search
@@ -196,7 +196,7 @@ export default class Danmuku {
|
||||
|
||||
this.option.speed = clamp(this.option.speed, 1, 10);
|
||||
this.option.opacity = clamp(this.option.opacity, 0, 1);
|
||||
this.option.fontSize = clamp(this.option.fontSize, 12, 100);
|
||||
this.option.fontSize = clamp(this.option.fontSize, 0, 100);
|
||||
|
||||
this.art.emit('artplayerPluginDanmuku:config', this.option);
|
||||
|
||||
@@ -320,7 +320,7 @@ export default class Danmuku {
|
||||
this.$danmuku.appendChild(danmu.$ref);
|
||||
danmu.$ref.style.visibility = 'visible';
|
||||
danmu.$ref.style.opacity = this.option.opacity;
|
||||
danmu.$ref.style.fontSize = `${this.option.fontSize}px`;
|
||||
danmu.$ref.style.fontSize = `${this.option.fontSize || danmu.fontSize}px`;
|
||||
danmu.$ref.innerText = danmu.text;
|
||||
danmu.$ref.style.color = danmu.color || '#fff';
|
||||
danmu.$ref.style.border = danmu.border ? `1px solid ${danmu.color || '#fff'}` : 'none';
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
function calculatedTop(danmus) {
|
||||
function calculatedTop(danmus, danmu) {
|
||||
// 方法1:两两对比,只要找到间隔能塞进一条弹幕的高度的,则马上插入
|
||||
for (let index = 1; index < danmus.length; index += 1) {
|
||||
const item = danmus[index];
|
||||
const prev = danmus[index - 1];
|
||||
const prevBottom = prev.top + prev.height;
|
||||
const diff = item.top - prevBottom;
|
||||
if (diff >= danmus[1].height) {
|
||||
if (diff >= danmu.$ref.clientHeight) {
|
||||
return prevBottom;
|
||||
}
|
||||
}
|
||||
@@ -41,10 +41,9 @@ export default function getDanmuTop(ins, danmu) {
|
||||
const danmus = ins.queue
|
||||
.filter((item) => {
|
||||
return (
|
||||
item.mode === danmu.mode &&
|
||||
item.$state === 'emit' &&
|
||||
item.$ref &&
|
||||
item.$ref.style.fontSize === danmu.$ref.style.fontSize &&
|
||||
item.$state === 'emit' &&
|
||||
item.mode === danmu.mode &&
|
||||
item.$ref.offsetTop <= $player.clientHeight - ins.marginBottom
|
||||
);
|
||||
})
|
||||
@@ -79,5 +78,5 @@ export default function getDanmuTop(ins, danmu) {
|
||||
width: $player.clientWidth,
|
||||
});
|
||||
|
||||
return calculatedTop(danmus);
|
||||
return calculatedTop(danmus, danmu);
|
||||
}
|
||||
Reference in new issue
Block a user