From 2161a5d0bf42b4d6ade6da7fb5611c66e514b7e9 Mon Sep 17 00:00:00 2001 From: anekos Date: Sun, 28 Mar 2010 14:20:34 +0000 Subject: オレオレ化 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37114 d0d07461-0603-4401-acd4-de1884942a52 --- spatial-navigation.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'spatial-navigation.js') 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) -- cgit v1.2.3