@lightningtv/core
Advanced tools
Comparing version 2.7.0-2 to 2.7.0-3
@@ -7,2 +7,3 @@ import type { RendererMainSettings } from '@lightningjs/renderer'; | ||
focusDebug: boolean; | ||
keyDebug: boolean; | ||
animationSettings?: AnimationSettings; | ||
@@ -9,0 +10,0 @@ animationsEnabled: boolean; |
@@ -8,2 +8,3 @@ function isDevEnv() { | ||
focusDebug: false, | ||
keyDebug: false, | ||
animationsEnabled: true, | ||
@@ -10,0 +11,0 @@ animationSettings: { |
@@ -1,2 +0,2 @@ | ||
import { Config } from './config.js'; | ||
import { Config, isDev } from './config.js'; | ||
import { isFunction } from './utils.js'; | ||
@@ -108,2 +108,3 @@ const keyMapEntries = { | ||
let finalFocusElm; | ||
let handlerAvailable; | ||
for (const elm of focusPath) { | ||
@@ -116,5 +117,7 @@ if (!finalFocusElm) | ||
: elm[`on${mappedEvent}`]; | ||
if (isFunction(eventHandler) && | ||
eventHandler.call(elm, e, elm, finalFocusElm) === true) { | ||
return true; | ||
if (isFunction(eventHandler)) { | ||
handlerAvailable = elm; | ||
if (eventHandler.call(elm, e, elm, finalFocusElm) === true) { | ||
return true; | ||
} | ||
} | ||
@@ -124,8 +127,18 @@ } | ||
const fallbackHandler = isHold ? elm.onKeyHold : elm.onKeyPress; | ||
if (isFunction(fallbackHandler) && | ||
fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm) === true) { | ||
return true; | ||
if (isFunction(fallbackHandler)) { | ||
handlerAvailable = elm; | ||
if (fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm) === true) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
if (isDev && Config.keyDebug && !isUp) { | ||
if (handlerAvailable) { | ||
console.log(`Keypress bubbled, key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`, handlerAvailable); | ||
} | ||
else { | ||
console.log(`No event handler available for keypress: key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`); | ||
} | ||
} | ||
return false; | ||
@@ -159,2 +172,3 @@ }; | ||
clearTimeout(keyHoldTimeouts[key]); | ||
delete keyHoldTimeouts[key]; | ||
// trigger key down event when hold didn't finish | ||
@@ -161,0 +175,0 @@ propagateKeyPress(keyup, mappedKeyEvent, false); |
{ | ||
"name": "@lightningtv/core", | ||
"version": "2.7.0-2", | ||
"version": "2.7.0-3", | ||
"description": "Lightning TV Core for Universal Renderers", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -12,2 +12,3 @@ import type { RendererMainSettings } from '@lightningjs/renderer'; | ||
focusDebug: boolean; | ||
keyDebug: boolean; | ||
animationSettings?: AnimationSettings; | ||
@@ -29,2 +30,3 @@ animationsEnabled: boolean; | ||
focusDebug: false, | ||
keyDebug: false, | ||
animationsEnabled: true, | ||
@@ -31,0 +33,0 @@ animationSettings: { |
@@ -1,2 +0,2 @@ | ||
import { Config } from './config.js'; | ||
import { Config, isDev } from './config.js'; | ||
export type * from './focusKeyTypes.js'; | ||
@@ -149,2 +149,3 @@ import { ElementNode } from './elementNode.js'; | ||
let finalFocusElm: ElementNode | undefined; | ||
let handlerAvailable: ElementNode | undefined; | ||
@@ -159,7 +160,7 @@ for (const elm of focusPath) { | ||
if ( | ||
isFunction(eventHandler) && | ||
eventHandler.call(elm, e, elm, finalFocusElm) === true | ||
) { | ||
return true; | ||
if (isFunction(eventHandler)) { | ||
handlerAvailable = elm; | ||
if (eventHandler.call(elm, e, elm, finalFocusElm) === true) { | ||
return true; | ||
} | ||
} | ||
@@ -170,7 +171,9 @@ } | ||
const fallbackHandler = isHold ? elm.onKeyHold : elm.onKeyPress; | ||
if ( | ||
isFunction(fallbackHandler) && | ||
fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm) === true | ||
) { | ||
return true; | ||
if (isFunction(fallbackHandler)) { | ||
handlerAvailable = elm; | ||
if ( | ||
fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm) === true | ||
) { | ||
return true; | ||
} | ||
} | ||
@@ -180,2 +183,15 @@ } | ||
if (isDev && Config.keyDebug && !isUp) { | ||
if (handlerAvailable) { | ||
console.log( | ||
`Keypress bubbled, key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`, | ||
handlerAvailable, | ||
); | ||
} else { | ||
console.log( | ||
`No event handler available for keypress: key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`, | ||
); | ||
} | ||
} | ||
return false; | ||
@@ -217,2 +233,3 @@ }; | ||
clearTimeout(keyHoldTimeouts[key]); | ||
delete keyHoldTimeouts[key]; | ||
// trigger key down event when hold didn't finish | ||
@@ -219,0 +236,0 @@ propagateKeyPress(keyup, mappedKeyEvent, false); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
235133
3671