mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -08:00
update
This commit is contained in:
1 parent
98b7f33fab
commit
617ac9e893
4 files changed
+42
-30
No files matched your search
@@ -273,25 +273,26 @@ class Danmuku {
|
||||
perspective: 500px;
|
||||
display: inline-block;
|
||||
will-change: transform;
|
||||
font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;
|
||||
font-weight: normal;
|
||||
line-height: 1.125;
|
||||
font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;
|
||||
text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px;
|
||||
`;
|
||||
return $ref;
|
||||
}
|
||||
async load() {
|
||||
this.queue = [];
|
||||
this.$danmuku.innerText = '';
|
||||
let danmus = [];
|
||||
try {
|
||||
let danmus = [];
|
||||
if (typeof this.option.danmuku === 'function') danmus = await this.option.danmuku();
|
||||
else if (typeof this.option.danmuku.then === 'function') danmus = await this.option.danmuku;
|
||||
else if (typeof this.option.danmuku === 'string') danmus = await _bilibili.bilibiliDanmuParseFromUrl(this.option.danmuku);
|
||||
else danmus = this.option.danmuku;
|
||||
this.utils.errorHandle(Array.isArray(danmus), 'Danmuku need return an array as result');
|
||||
this.art.emit('artplayerPluginDanmuku:loaded', danmus);
|
||||
danmus.forEach(this.emit.bind(this));
|
||||
this.queue = [];
|
||||
this.$danmuku.innerText = '';
|
||||
danmus.forEach((danmu)=>this.emit(danmu)
|
||||
);
|
||||
} catch (error) {
|
||||
this.art.emit('artplayerPluginDanmuku:error', error);
|
||||
throw error;
|
||||
@@ -309,6 +310,7 @@ class Danmuku {
|
||||
return this;
|
||||
}
|
||||
continue() {
|
||||
const { clientWidth } = this.$player;
|
||||
this.filter('stop', (danmu)=>{
|
||||
danmu.$state = 'emit';
|
||||
danmu.$ref.dataset.state = 'emit';
|
||||
@@ -316,7 +318,7 @@ class Danmuku {
|
||||
switch(danmu.mode){
|
||||
case 0:
|
||||
{
|
||||
const translateX = this.$player.clientWidth + danmu.$ref.clientWidth;
|
||||
const translateX = clientWidth + danmu.$ref.clientWidth;
|
||||
danmu.$ref.style.transform = `translateX(${-translateX}px) translateY(0px) translateZ(0px)`;
|
||||
danmu.$ref.style.transition = `transform ${danmu.$restTime}s linear 0s`;
|
||||
break;
|
||||
@@ -328,13 +330,14 @@ class Danmuku {
|
||||
return this;
|
||||
}
|
||||
suspend() {
|
||||
const { clientWidth } = this.$player;
|
||||
this.filter('emit', (danmu)=>{
|
||||
danmu.$state = 'stop';
|
||||
danmu.$ref.dataset.state = 'stop';
|
||||
switch(danmu.mode){
|
||||
case 0:
|
||||
{
|
||||
const translateX = this.$player.clientWidth - (this.getLeft(danmu.$ref) - this.getLeft(this.$player));
|
||||
const translateX = clientWidth - (this.getLeft(danmu.$ref) - this.getLeft(this.$player));
|
||||
danmu.$ref.style.transform = `translateX(${-translateX}px) translateY(0px) translateZ(0px)`;
|
||||
danmu.$ref.style.transition = 'transform 0s linear 0s';
|
||||
break;
|
||||
@@ -346,11 +349,12 @@ class Danmuku {
|
||||
return this;
|
||||
}
|
||||
resize() {
|
||||
this.filter('wait', (danmu)=>{
|
||||
const { clientWidth } = this.$player;
|
||||
this.queue.forEach((danmu)=>{
|
||||
if (danmu.$ref) {
|
||||
danmu.$ref.style.border = 'none';
|
||||
danmu.$ref.style.marginLeft = '0px';
|
||||
danmu.$ref.style.left = `${this.$player.clientWidth}px`;
|
||||
danmu.$ref.style.left = `${clientWidth}px`;
|
||||
danmu.$ref.style.transform = 'translateX(0px) translateY(0px) translateZ(0px)';
|
||||
danmu.$ref.style.transition = 'transform 0s linear 0s';
|
||||
}
|
||||
@@ -358,6 +362,7 @@ class Danmuku {
|
||||
return this;
|
||||
}
|
||||
reset() {
|
||||
const { clientWidth } = this.$player;
|
||||
this.filter('emit', (danmu)=>{
|
||||
if (danmu.$ref) {
|
||||
danmu.$state = 'wait';
|
||||
@@ -365,13 +370,14 @@ class Danmuku {
|
||||
danmu.$ref.style.border = 'none';
|
||||
danmu.$ref.style.visibility = 'hidden';
|
||||
danmu.$ref.style.marginLeft = '0px';
|
||||
danmu.$ref.style.left = `${this.$player.clientWidth}px`;
|
||||
danmu.$ref.style.left = `${clientWidth}px`;
|
||||
danmu.$ref.style.transform = 'translateX(0px) translateY(0px) translateZ(0px)';
|
||||
danmu.$ref.style.transition = 'transform 0s linear 0s';
|
||||
}
|
||||
});
|
||||
}
|
||||
update() {
|
||||
const { clientWidth } = this.$player;
|
||||
this.animationFrameTimer = window.requestAnimationFrame(()=>{
|
||||
if (this.art.playing && !this.isHide) {
|
||||
this.filter('emit', (danmu)=>{
|
||||
@@ -385,7 +391,7 @@ class Danmuku {
|
||||
danmu.$ref.style.border = 'none';
|
||||
danmu.$ref.style.visibility = 'hidden';
|
||||
danmu.$ref.style.marginLeft = '0px';
|
||||
danmu.$ref.style.left = `${this.$player.clientWidth}px`;
|
||||
danmu.$ref.style.left = `${clientWidth}px`;
|
||||
danmu.$ref.style.transform = 'translateX(0px) translateY(0px) translateZ(0px)';
|
||||
danmu.$ref.style.transition = 'transform 0s linear 0s';
|
||||
}
|
||||
@@ -409,8 +415,8 @@ class Danmuku {
|
||||
case 0:
|
||||
{
|
||||
danmu.$ref.style.top = `${danmuTop}px`;
|
||||
danmu.$ref.style.left = `${this.$player.clientWidth}px`;
|
||||
const translateX = this.$player.clientWidth + danmu.$ref.clientWidth;
|
||||
danmu.$ref.style.left = `${clientWidth}px`;
|
||||
const translateX = clientWidth + danmu.$ref.clientWidth;
|
||||
danmu.$ref.style.transform = `translateX(${-translateX}px) translateY(0px) translateZ(0px)`;
|
||||
danmu.$ref.style.transition = `transform ${danmu.$restTime}s linear 0s`;
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user