aboutsummaryrefslogtreecommitdiffstats
path: root/spatial-navigation.js
diff options
context:
space:
mode:
Diffstat (limited to 'spatial-navigation.js')
-rwxr-xr-xspatial-navigation.js25
1 files changed, 10 insertions, 15 deletions
diff --git a/spatial-navigation.js b/spatial-navigation.js
index b37ab34..fcd6991 100755
--- a/spatial-navigation.js
+++ b/spatial-navigation.js
@@ -109,22 +109,17 @@ let g:spatial_navigation_mappings="<A-h> <A-j> <A-k> <A-l>"
window.document.commandDispatcher.focusedElement;
function isRectInDirection (dir, focusedRect, anotherRect) {
- if (dir === DIR.L) {
- return (anotherRect.left < focusedRect.left);
- }
-
- if (dir === DIR.R) {
- return (anotherRect.right > focusedRect.right);
- }
-
- if (dir === DIR.U) {
- return (anotherRect.top < focusedRect.top);
- }
-
- if (dir === DIR.D) {
- return (anotherRect.bottom > focusedRect.bottom);
+ switch (dir) {
+ case DIR.L:
+ return anotherRect.left < focusedRect.left;
+ case DIR.R:
+ return anotherRect.right > focusedRect.right;
+ case DIR.U:
+ return anotherRect.top < focusedRect.top;
+ case DIR.D:
+ return anotherRect.bottom > focusedRect.bottom
}
- return false;
+ return false;
}
function inflateRect (rect, value) {