Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aim

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aim - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

167

dist/index.js

@@ -56,22 +56,28 @@ const $1906921049_autoFocus = (aim, set) => {

}
let next
for (let i = 0, l = children.length, diff; i < l; i++) {
const next = children[i]
const a = x - next.xMid - xOffset
const b = y - next.yMid - yOffset
const c = Math.sqrt(a * a + b * b)
if (diff === void 0 || c < diff) {
if (top || bottom) {
if (next.y + yOffset >= bottom || next.yEnd + yOffset <= top) {
continue
if (i in children) {
next = children[i]
const a = x - next.xMid - xOffset
const b = y - next.yMid - yOffset
const c = Math.sqrt(a * a + b * b)
if (diff === void 0 || c < diff) {
if (top || bottom) {
if (next.y + yOffset >= bottom || next.yEnd + yOffset <= top) {
continue
}
}
}
if (left || right) {
if (next.x + xOffset >= right || next.xEnd + xOffset <= left) {
continue
if (left || right) {
if (next.x + xOffset >= right || next.xEnd + xOffset <= left) {
continue
}
}
child = next
diff = c
}
child = next
diff = c
}
}
if (!next) {
return
}
}

@@ -88,8 +94,18 @@ }

if (parent.direction === direction) {
let sibling = target
// if direction is correct walk (delta) sibling
while ((sibling = parent.children[sibling.index + delta])) {
const child = $1906921049_findClosestDescendant(aim, sibling)
// if new focus return
if ($1906921049_focusElement(aim, child)) return child
let i = target.index
if (delta < 0) {
for (; i >= 0; i--) {
if (i in parent.children) {
const child = $1906921049_findClosestDescendant(aim, parent.children[i])
if (child && $1906921049_focusElement(aim, child)) return child
}
}
} else {
for (let l = parent.children.length; i < l; i++) {
if (i in parent.children) {
const child = $1906921049_findClosestDescendant(aim, parent.children[i])
if (child && $1906921049_focusElement(aim, child)) return child
}
}
}

@@ -110,3 +126,5 @@ }

;const $1870128113_createBranch = (parent, index) => {
if (!(index in parent.children)) {
if (index in parent.children) {
return parent.children[index]
} else {
const child = { index, children: [], parent }

@@ -116,3 +134,12 @@ if (parent.direction === 'y') {

child.x = parent.x
child.y = index ? $1870128113_createBranch(parent, index - 1).yEnd : parent.y
// child.y = index ? createBranch(parent, index - 1).yEnd : parent.y
child.y = parent.y
if (index) {
for (let i = index - 1; i >= 0; i--) {
if (i in parent.children) {
child.y = parent.children[i].yEnd
break
}
}
}
child.xEnd = parent.xEnd

@@ -123,3 +150,12 @@ child.yEnd = child.y

child.y = parent.y
child.x = index ? $1870128113_createBranch(parent, index - 1).xEnd : parent.x
// child.x = index ? createBranch(parent, index - 1).xEnd : parent.x
child.x = parent.x
if (index) {
for (let i = index - 1; i >= 0; i--) {
if (i in parent.children) {
child.x = parent.children[i].xEnd
break
}
}
}
child.yEnd = parent.yEnd

@@ -129,4 +165,2 @@ child.xEnd = child.x

return (parent.children[index] = child)
} else {
return parent.children[index]
}

@@ -138,5 +172,25 @@ }

if (!('x' in set)) set.x = parent.x
if (!('y' in set)) set.y = index ? parent.children[index - 1].yEnd : parent.y
if (!('y' in set)) {
set.y = parent.y
if (index) {
for (let i = index - 1; i >= 0; i--) {
if (i in parent.children) {
set.y = parent.children[i].yEnd
break
}
}
}
}
} else {
if (!('x' in set)) set.x = index ? parent.children[index - 1].xEnd : parent.x
if (!('x' in set)) {
set.x = parent.x
if (index) {
for (let i = index - 1; i >= 0; i--) {
if (i in parent.children) {
set.x = parent.children[i].xEnd
break
}
}
}
}
if (!('y' in set)) set.y = parent.y

@@ -168,3 +222,3 @@ }

for (var i = child.children.length - 1; i >= 0; i--) {
$3174120555_updateX(child.children[i], xDiff)
if (i in child.children) $3174120555_updateX(child.children[i], xDiff)
}

@@ -180,3 +234,3 @@ }

for (var i = child.children.length - 1; i >= 0; i--) {
$3174120555_updateX(child.children[i], xDiff)
if (i in child.children) $3174120555_updateX(child.children[i], xDiff)
}

@@ -190,12 +244,19 @@ }

if ('parent' in parent) {
const siblings = parent.parent.children
let l = siblings.length
if (parent.direction === 'x') {
const siblings = parent.parent.children
for (var i = siblings.length - 1; i >= 0; i--) {
const sibling = siblings[i]
sibling.xEnd = xEnd
sibling.xMid = parent.xMid
for (let i = l - 1; i >= 0; i--) {
if (i in siblings) {
const sibling = siblings[i]
sibling.xEnd = xEnd
sibling.xMid = parent.xMid
}
}
} else {
const nextSibling = parent.parent.children[parent.index + 1]
if (nextSibling) $3174120555_updateX(nextSibling, xEnd - parent.xEnd)
for (let i = parent.index + 1; i < l; i++) {
if (i in siblings) {
$3174120555_updateX(siblings[i], xEnd - parent.xEnd)
break
}
}
}

@@ -212,12 +273,19 @@ }

if ('parent' in parent) {
const siblings = parent.parent.children
let l = siblings.length
if (parent.direction === 'y') {
const siblings = parent.parent.children
for (var i = siblings.length - 1; i >= 0; i--) {
const sibling = siblings[i]
sibling.yEnd = yEnd
sibling.yMid = parent.yMid
for (let i = l - 1; i >= 0; i--) {
if (i in siblings) {
const sibling = siblings[i]
sibling.yEnd = yEnd
sibling.yMid = parent.yMid
}
}
} else {
const nextSibling = parent.parent.children[parent.index + 1]
if (nextSibling) $3174120555_updateY(nextSibling, yEnd - parent.yEnd)
for (let i = parent.index + 1; i < l; i++) {
if (i in siblings) {
$3174120555_updateY(siblings[i], yEnd - parent.yEnd)
break
}
}
}

@@ -289,3 +357,3 @@ }

left: {
name: 'onLeft',
name: 'onArrowLeft',
direction: 'x',

@@ -295,3 +363,3 @@ delta: -1

right: {
name: 'onRight',
name: 'onArrowRight',
direction: 'x',

@@ -301,3 +369,3 @@ delta: 1

up: {
name: 'onUp',
name: 'onArrowUp',
direction: 'y',

@@ -307,3 +375,3 @@ delta: -1

down: {
name: 'onDown',
name: 'onArrowDown',
direction: 'y',

@@ -347,5 +415,6 @@ delta: 1

const event = $3174120555_keys[e.keyCode]
const handled = event.name in $3174120555_aim.currentFocus &&
$3174120555_aim.currentFocus[event.name]($3174120555_aim.currentFocus)
if (handled === false && 'direction' in event) {
if (event.name in $3174120555_aim.currentFocus) {
var handled = $3174120555_aim.currentFocus[event.name]($3174120555_aim.currentFocus)
}
if (handled !== false && 'direction' in event) {
if ($1906921049_changeFocus($3174120555_aim, event.direction, event.delta)) {

@@ -352,0 +421,0 @@ e.preventDefault()

@@ -17,4 +17,6 @@ const $2059854641_renderChild = (aim, root, target, position) => {

for (let i = 0, l = target.children.length; i < l; i++) {
const child = target.children[i]
root.appendChild($2059854641_renderChild(aim, root, child, position.concat(child.index)))
if (i in target.children) {
const child = target.children[i]
root.appendChild($2059854641_renderChild(aim, root, child, position.concat(child.index)))
}
}

@@ -21,0 +23,0 @@ } else {

{
"name": "aim",
"version": "0.0.5",
"main": "dist/index.js",

@@ -23,4 +24,3 @@ "description": "Dependency free focus manager with built-in universal key navigation.",

"task": "latest"
},
"version": "0.0.4"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc