mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -08:00
add dblclick event
This commit is contained in:
1 parent
6ad6e8fddc
commit
9697a61526
4 files changed
+52
-23
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import { includeFromEvent } from '../utils';
|
||||
import { includeFromEvent, isMobile } from '../utils';
|
||||
|
||||
export default function clickInit(art, events) {
|
||||
const {
|
||||
template: { $player },
|
||||
template: { $player, $video },
|
||||
} = art;
|
||||
|
||||
events.proxy(document, ['click', 'contextmenu'], (event) => {
|
||||
@@ -14,4 +14,27 @@ export default function clickInit(art, events) {
|
||||
art.emit('blur');
|
||||
}
|
||||
});
|
||||
|
||||
let clickTime = 0;
|
||||
events.proxy($video, 'click', () => {
|
||||
const now = Date.now();
|
||||
|
||||
if (now - clickTime <= 300) {
|
||||
art.emit('dblclick');
|
||||
|
||||
if (isMobile) {
|
||||
art.toggle();
|
||||
} else {
|
||||
art.fullscreen = !art.fullscreen;
|
||||
}
|
||||
} else {
|
||||
art.emit('click');
|
||||
|
||||
if (!isMobile) {
|
||||
art.toggle();
|
||||
}
|
||||
}
|
||||
|
||||
clickTime = now;
|
||||
});
|
||||
}
|
||||
@@ -13,16 +13,6 @@ export default function eventInit(art) {
|
||||
let reconnectTime = 0;
|
||||
const maxReconnectTime = 5;
|
||||
|
||||
proxy($video, 'click', () => {
|
||||
if (!isMobile) {
|
||||
art.toggle();
|
||||
}
|
||||
});
|
||||
|
||||
proxy($video, 'dblclick', () => {
|
||||
art.fullscreen = !art.fullscreen;
|
||||
});
|
||||
|
||||
for (let index = 0; index < config.events.length; index++) {
|
||||
proxy($video, config.events[index], (event) => {
|
||||
art.emit(`video:${event.type}`, event);
|
||||
|
||||
Reference in new issue
Block a user