Comparing version 0.0.5 to 0.0.6
@@ -15,7 +15,7 @@ const $1906921049_autoFocus = (aim, set) => { | ||
aim.currentFocusAttempt = target | ||
if (!('onFocus' in target) || target.onFocus(target, aim) !== false) { | ||
if (!('onFocus' in target) || target.onFocus(target) !== false) { | ||
const blurTarget = aim.currentFocus | ||
aim.currentFocus = target | ||
if (blurTarget && 'onBlur' in blurTarget) { | ||
blurTarget.onBlur(blurTarget, aim) | ||
blurTarget.onBlur(blurTarget) | ||
} | ||
@@ -368,2 +368,5 @@ return target | ||
name: 'onEnter' | ||
}, | ||
back: { | ||
name: 'onBack' | ||
} | ||
@@ -377,3 +380,4 @@ } | ||
39: $3174120555_events.right, | ||
40: $3174120555_events.down | ||
40: $3174120555_events.down, | ||
8: $3174120555_events.back | ||
} | ||
@@ -404,7 +408,12 @@ | ||
if (event.name in $3174120555_aim.currentFocus) { | ||
var handled = $3174120555_aim.currentFocus[event.name]($3174120555_aim.currentFocus) | ||
var useDefaultBehaviour = $3174120555_aim.currentFocus[event.name]($3174120555_aim.currentFocus) | ||
} | ||
if (handled !== false && 'direction' in event) { | ||
if ($1906921049_changeFocus($3174120555_aim, event.direction, event.delta)) { | ||
e.preventDefault() | ||
if (useDefaultBehaviour === false) { | ||
return $3174120555_aim.currentFocus | ||
} else { | ||
if ('direction' in event) { | ||
if ($1906921049_changeFocus($3174120555_aim, event.direction, event.delta)) { | ||
e.preventDefault() | ||
return $3174120555_aim.currentFocus | ||
} | ||
} | ||
@@ -433,6 +442,5 @@ } | ||
unregister (target) { | ||
const index = target.index | ||
var index = target.index | ||
var children = target.parent.children | ||
var length | ||
if ($3174120555_aim.currentFocus === target) { | ||
@@ -451,5 +459,10 @@ const sibling = children[index ? index - 1 : index + 1] | ||
children = target.children | ||
index = target.index | ||
} | ||
for (var i = index + 1; i < length; i++) { | ||
children[children[i].index = i - 1] = children[i] | ||
if (i in children) { | ||
children[children[i].index = i - 1] = children[i] | ||
} else { | ||
delete children[i - 1] | ||
} | ||
} | ||
@@ -456,0 +469,0 @@ children.pop() |
{ | ||
"name": "aim", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "description": "Dependency free focus manager with built-in universal key navigation.", |
18820
515