@silkytone/danmu
Version:
弹幕的简单实现,实现普通弹幕或高级弹幕。
22 lines (18 loc) • 517 B
text/typescript
// barrage/text.ts
import { BarrageBase } from './barrage';
import { VNode } from '../utils';
// TODO: 文本弹幕
export class TextBarrage extends BarrageBase<HTMLDivElement> {
readonly duration: number;
constructor(text: string, duration = 3) {
super(VNode('div', {
class: 'var-barrage-item is-text',
style: { display: 'inline-block' },
}, [
VNode('span', {}, [text]),
]) as HTMLDivElement);
//
this.duration = duration;
this.$el.style.whiteSpace = 'nowrap';
}
}