mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migrate mouseManager to es6
This commit is contained in:
parent
5d2d8d2855
commit
1f3bc8a427
2 changed files with 29 additions and 21 deletions
|
@ -266,6 +266,7 @@
|
||||||
"src/scripts/inputManager.js",
|
"src/scripts/inputManager.js",
|
||||||
"src/scripts/keyboardNavigation.js",
|
"src/scripts/keyboardNavigation.js",
|
||||||
"src/scripts/libraryBrowser.js",
|
"src/scripts/libraryBrowser.js",
|
||||||
|
"src/scripts/mouseManager.js",
|
||||||
"src/scripts/multiDownload.js",
|
"src/scripts/multiDownload.js",
|
||||||
"src/scripts/playlists.js",
|
"src/scripts/playlists.js",
|
||||||
"src/scripts/routes.js",
|
"src/scripts/routes.js",
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'dom'], function (inputManager, focusManager, browser, layoutManager, events, dom) {
|
import inputManager from 'inputManager';
|
||||||
'use strict';
|
import focusManager from 'focusManager';
|
||||||
|
import browser from 'browser';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import events from 'events';
|
||||||
|
import dom from 'dom';
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
var self = {};
|
const self = {};
|
||||||
|
|
||||||
var lastMouseInputTime = new Date().getTime();
|
let lastMouseInputTime = new Date().getTime();
|
||||||
var isMouseIdle;
|
let isMouseIdle;
|
||||||
|
|
||||||
function mouseIdleTime() {
|
function mouseIdleTime() {
|
||||||
return new Date().getTime() - lastMouseInputTime;
|
return new Date().getTime() - lastMouseInputTime;
|
||||||
|
@ -15,14 +20,14 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeIdleClasses() {
|
function removeIdleClasses() {
|
||||||
var classList = document.body.classList;
|
const classList = document.body.classList;
|
||||||
|
|
||||||
classList.remove('mouseIdle');
|
classList.remove('mouseIdle');
|
||||||
classList.remove('mouseIdle-tv');
|
classList.remove('mouseIdle-tv');
|
||||||
}
|
}
|
||||||
|
|
||||||
function addIdleClasses() {
|
function addIdleClasses() {
|
||||||
var classList = document.body.classList;
|
const classList = document.body.classList;
|
||||||
|
|
||||||
classList.add('mouseIdle');
|
classList.add('mouseIdle');
|
||||||
|
|
||||||
|
@ -31,7 +36,7 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCursor() {
|
export function showCursor() {
|
||||||
if (isMouseIdle) {
|
if (isMouseIdle) {
|
||||||
isMouseIdle = false;
|
isMouseIdle = false;
|
||||||
removeIdleClasses();
|
removeIdleClasses();
|
||||||
|
@ -39,7 +44,7 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideCursor() {
|
export function hideCursor() {
|
||||||
if (!isMouseIdle) {
|
if (!isMouseIdle) {
|
||||||
isMouseIdle = true;
|
isMouseIdle = true;
|
||||||
addIdleClasses();
|
addIdleClasses();
|
||||||
|
@ -47,17 +52,17 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastPointerMoveData;
|
let lastPointerMoveData;
|
||||||
function onPointerMove(e) {
|
function onPointerMove(e) {
|
||||||
var eventX = e.screenX;
|
const eventX = e.screenX;
|
||||||
var eventY = e.screenY;
|
const eventY = e.screenY;
|
||||||
|
|
||||||
// if coord don't exist how could it move
|
// if coord don't exist how could it move
|
||||||
if (typeof eventX === 'undefined' && typeof eventY === 'undefined') {
|
if (typeof eventX === 'undefined' && typeof eventY === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var obj = lastPointerMoveData;
|
const obj = lastPointerMoveData;
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
lastPointerMoveData = {
|
lastPointerMoveData = {
|
||||||
x: eventX,
|
x: eventX,
|
||||||
|
@ -81,11 +86,11 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPointerEnter(e) {
|
function onPointerEnter(e) {
|
||||||
var pointerType = e.pointerType || (layoutManager.mobile ? 'touch' : 'mouse');
|
const pointerType = e.pointerType || (layoutManager.mobile ? 'touch' : 'mouse');
|
||||||
|
|
||||||
if (pointerType === 'mouse') {
|
if (pointerType === 'mouse') {
|
||||||
if (!isMouseIdle) {
|
if (!isMouseIdle) {
|
||||||
var parent = focusManager.focusableParent(e.target);
|
const parent = focusManager.focusableParent(e.target);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
focusManager.focus(parent);
|
focusManager.focus(parent);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +120,7 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mouseInterval;
|
let mouseInterval;
|
||||||
function startMouseInterval() {
|
function startMouseInterval() {
|
||||||
if (!mouseInterval) {
|
if (!mouseInterval) {
|
||||||
mouseInterval = setInterval(onMouseInterval, 5000);
|
mouseInterval = setInterval(onMouseInterval, 5000);
|
||||||
|
@ -123,7 +128,7 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopMouseInterval() {
|
function stopMouseInterval() {
|
||||||
var interval = mouseInterval;
|
const interval = mouseInterval;
|
||||||
|
|
||||||
if (interval) {
|
if (interval) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
@ -167,8 +172,10 @@ define(['inputManager', 'focusManager', 'browser', 'layoutManager', 'events', 'd
|
||||||
|
|
||||||
events.on(layoutManager, 'modechange', initMouse);
|
events.on(layoutManager, 'modechange', initMouse);
|
||||||
|
|
||||||
self.hideCursor = hideCursor;
|
/* eslint-enable indent */
|
||||||
self.showCursor = showCursor;
|
|
||||||
|
export default {
|
||||||
|
hideCursor,
|
||||||
|
showCursor
|
||||||
|
};
|
||||||
|
|
||||||
return self;
|
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue