diff options
-rwxr-xr-x | spatial-navigation.js | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/spatial-navigation.js b/spatial-navigation.js index 6e47bf0..5f3f30b 100755 --- a/spatial-navigation.js +++ b/spatial-navigation.js @@ -122,26 +122,19 @@ let g:spatial_navigation_mappings="<A-h> <A-j> <A-k> <A-l>" return false; } - function inflateRect (rect, value) { - var newRect = new Object(); - - newRect.left = rect.left - value; - newRect.top = rect.top - value; - newRect.right = rect.right + value; - newRect.bottom = rect.bottom + value; - return newRect; - } + function inflateRect (rect, value) ({ + left: rect.left - value, + top: rect.top - value, + right: rect.right + value, + bottom: rect.bottom + value + }); - function containsRect (a, b) { - return ( (b.left <= a.right) && - (b.right >= a.left) && - (b.top <= a.bottom) && - (b.bottom >= a.top) ); - } + function containsRect (a, b) + ((b.left <= a.right) && (b.right >= a.left) && (b.top <= a.bottom) && (b.bottom >= a.top)); function spatialDistance (dir, a, b) { - var inlineNavigation = false; - var mx, my, nx, ny; + let inlineNavigation = false; + let mx, my, nx, ny; if (dir === DIR.L) { @@ -279,7 +272,7 @@ let g:spatial_navigation_mappings="<A-h> <A-j> <A-k> <A-l>" inlineNavigation = containsRect(scopedRect, b); } - var d = Math.pow((mx-nx), 2) + Math.pow((my-ny), 2); + let d = Math.pow((mx-nx), 2) + Math.pow((my-ny), 2); // prefer elements directly aligned with the focused element if (inlineNavigation) |