mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 09:41:20 -08:00
优化事件互斥关系
This commit is contained in:
1 parent
cf22fb0535
commit
634e776d49
8 files changed
+41
-27
No files matched your search
@@ -5,7 +5,7 @@ export default function resizeInit(art, events) {
|
||||
|
||||
const resizeFn = throttle(() => {
|
||||
if (option.autoSize) {
|
||||
if (!player.fullscreen && !player.fullscreenWeb && !player.pip) {
|
||||
if (!player.fullscreen && !player.fullscreenWeb && !player.fullscreenRotate && !player.pip) {
|
||||
player.autoSize = true;
|
||||
} else {
|
||||
player.autoSize = false;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export default function exclusiveInit(art, player) {
|
||||
const props = ['pip', 'fullscreen', 'fullscreenWeb', 'fullscreenRotate'];
|
||||
props.forEach((name) => {
|
||||
const event = `${name}Change`;
|
||||
art.on(event, (state) => {
|
||||
if (state) {
|
||||
props
|
||||
.filter((item) => item !== name)
|
||||
.forEach((item) => {
|
||||
if (player[item]) {
|
||||
player[item] = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -9,10 +9,6 @@ export default function fullscreenMix(art, player) {
|
||||
return screenfull.isFullscreen;
|
||||
},
|
||||
set(value) {
|
||||
if (player.fullscreenWeb) {
|
||||
player.fullscreenWeb = false;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
screenfull.request($player).then(() => {
|
||||
addClass($player, 'art-fullscreen');
|
||||
|
||||
@@ -8,10 +8,6 @@ export default function fullscreenWebMix(art, player) {
|
||||
return hasClass($player, 'art-fullscreen-web');
|
||||
},
|
||||
set(value) {
|
||||
if (player.fullscreen) {
|
||||
player.fullscreen = false;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
addClass($player, 'art-fullscreen-web');
|
||||
player.aspectRatioReset = true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import urlMix from './urlMix';
|
||||
import attrInit from './attrInit';
|
||||
import eventInit from './eventInit';
|
||||
import exclusiveInit from './exclusiveInit';
|
||||
import playMix from './playMix';
|
||||
import pauseMix from './pauseMix';
|
||||
import toggleMix from './toggleMix';
|
||||
@@ -30,6 +31,7 @@ export default class Player {
|
||||
urlMix(art, this);
|
||||
eventInit(art, this);
|
||||
attrInit(art, this);
|
||||
exclusiveInit(art, this);
|
||||
playMix(art, this);
|
||||
pauseMix(art, this);
|
||||
toggleMix(art, this);
|
||||
|
||||
@@ -114,8 +114,6 @@ function customPip(art, player) {
|
||||
const $body = document.body;
|
||||
setStyle($player, 'top', `${$body.clientHeight - player.height - 50}px`);
|
||||
setStyle($player, 'left', `${$body.clientWidth - player.width - 50}px`);
|
||||
player.fullscreen = false;
|
||||
player.fullscreenWeb = false;
|
||||
player.aspectRatio = false;
|
||||
player.playbackRate = false;
|
||||
art.emit('pipChange', true);
|
||||
@@ -124,8 +122,6 @@ function customPip(art, player) {
|
||||
removeClass($player, 'art-pip');
|
||||
setStyle($player, 'top', null);
|
||||
setStyle($player, 'left', null);
|
||||
player.fullscreen = false;
|
||||
player.fullscreenWeb = false;
|
||||
player.aspectRatio = false;
|
||||
player.playbackRate = false;
|
||||
player.autoSize = true;
|
||||
|
||||
Reference in new issue
Block a user