update sw.js

This commit is contained in:
Harvey committed 2022-04-29 17:43:20 +08:00
1 parent b53deb5ad8
commit 227268ecda
12 files changed
+61 -114

No files matched your search

@@ -219,7 +219,7 @@ export default class Danmuku {
resize() {
const { $player } = this.art.template;
const { left: playerLeft, width: playerWidth } = this.getRect($player);
const { width: playerWidth } = this.getRect($player);
this.filter('wait', (danmu) => {
if (danmu.$ref) {
@@ -231,32 +231,6 @@ export default class Danmuku {
}
});
this.filter('emit', (danmu) => {
switch (danmu.mode) {
case 0: {
const { left: danmuLeft } = this.getRect(danmu.$ref);
const translateX = playerWidth - (danmuLeft - playerLeft);
danmu.$ref.style.transform = `translateX(${-translateX}px) translateY(0px) translateZ(0px)`;
break;
}
default:
break;
}
});
this.filter('stop', (danmu) => {
switch (danmu.mode) {
case 0: {
const { left: danmuLeft } = this.getRect(danmu.$ref);
const translateX = playerWidth - (danmuLeft - playerLeft);
danmu.$ref.style.transform = `translateX(${-translateX}px) translateY(0px) translateZ(0px)`;
break;
}
default:
break;
}
});
return this;
}
@@ -293,7 +267,6 @@ export default class Danmuku {
.forEach((danmu) => {
danmu.$ref = this.getDanmuRef(this.queue);
this.$danmuku.appendChild(danmu.$ref);
danmu.$ref.__danmu__ = danmu;
danmu.$ref.style.visibility = 'visible';
danmu.$ref.style.opacity = this.option.opacity;
danmu.$ref.style.fontSize = `${this.option.fontSize}px`;
+9 -20
View File
@@ -2,29 +2,18 @@ import { def } from '../utils';
export default function exclusiveMix(art) {
const sizeProps = ['mini', 'pip', 'fullscreen', 'fullscreenWeb'];
function exclusive(props) {
for (let index = 0; index < props.length; index++) {
const name = props[index];
art.on(name, () => {
if (art[name]) {
props
.filter((item) => item !== name)
.forEach((item) => {
if (art[item]) {
art[item] = false;
}
});
}
});
}
}
exclusive(sizeProps);
def(art, 'normalSize', {
get() {
return sizeProps.every((name) => !art[name]);
},
set(name) {
sizeProps
.filter((item) => item !== name)
.forEach((item) => {
if (art[item]) {
art[item] = false;
}
});
},
});
}
@@ -15,19 +15,20 @@ const nativeScreenfull = (art) => {
},
set(value) {
if (value) {
art.normalSize = 'fullscreen';
art.aspectRatioReset = true;
art.autoSize = false;
screenfull.request($player).then(() => {
addClass($player, 'art-fullscreen');
art.aspectRatioReset = true;
art.autoSize = false;
art.emit('resize');
art.emit('fullscreen', true);
notice.show = '';
});
} else {
art.aspectRatioReset = true;
art.autoSize = art.option.autoSize;
screenfull.exit().then(() => {
removeClass($player, 'art-fullscreen');
art.aspectRatioReset = true;
art.autoSize = art.option.autoSize;
art.emit('resize');
art.emit('fullscreen');
notice.show = '';
@@ -49,6 +50,7 @@ const webkitScreenfull = (art) => {
},
set(value) {
if (value) {
art.normalSize = 'fullscreen';
$video.webkitEnterFullscreen();
art.emit('fullscreen', true);
notice.show = '';
@@ -12,6 +12,7 @@ export default function fullscreenWebMix(art) {
},
set(value) {
if (value) {
art.normalSize = 'fullscreenWeb';
addClass($player, 'art-fullscreen-web');
art.aspectRatioReset = true;
art.autoSize = false;
+1
View File
@@ -55,6 +55,7 @@ export default function miniMix(art) {
},
set(value) {
if (value) {
art.normalSize = 'mini';
art.autoSize = false;
cacheStyle = $player.style.cssText;
addClass($player, 'art-mini');
+2
View File
@@ -15,6 +15,7 @@ function nativePip(art) {
},
set(value) {
if (value) {
art.normalSize = 'pip';
$video.requestPictureInPicture().catch((err) => {
notice.show = err;
throw err;
@@ -48,6 +49,7 @@ function webkitPip(art) {
},
set(value) {
if (value) {
art.normalSize = 'pip';
$video.webkitSetPresentationMode('picture-in-picture');
art.emit('pip', true);
} else {