src/directives/kbItem.js
function distance(direction, currentRect, targetRect) {
                if (direction === 'left' && targetRect.left < currentRect.left) {
                    return currentRect.left - targetRect.left;
                }
                if (direction === 'up' && targetRect.top < currentRect.top) {
                    return currentRect.top - targetRect.top;
                }
                if (direction === 'right' && targetRect.left > currentRect.left) {
                    return targetRect.left - currentRect.left;
                }
                if (direction === 'down' && targetRect.top > currentRect.top) {
                    return targetRect.top - currentRect.top;
                }
                return 0;
            }
function distance(direction, currentRect, targetRect) {
                if (direction === 'left' && targetRect.left < currentRect.left) {
                    return currentRect.left - targetRect.left;
                }
                if (direction === 'up' && targetRect.top < currentRect.top) {
                    return currentRect.top - targetRect.top;
                }
                if (direction === 'right' && targetRect.left > currentRect.left) {
                    return targetRect.left - currentRect.left;
                }
                if (direction === 'down' && targetRect.top > currentRect.top) {
                    return targetRect.top - currentRect.top;
                }
                return 0;
            }
function distance ( direction , currentRect , targetRect ) { if ( direction === 'left' && targetRect . left < currentRect . left ) { return currentRect . left - targetRect . left ; } if ( direction === 'up' && targetRect . top < currentRect . top ) { return currentRect . top - targetRect . top ; } if ( direction === 'right' && targetRect . left > currentRect . left ) { return targetRect . left - currentRect . left ; } if ( direction === 'down' && targetRect . top > currentRect . top ) { return targetRect . top - currentRect . top ; } return 0 ; }
Calculates the distance to the ClientRect in a given direction.
Allows for keyboard navigation based on the relative visual location of the element.

@param {string} direction 'up', 'left', 'right' or 'down',
@param {ClientRect} currentRect The position of the current item.
@return {Number}
Calculates the distance to the ClientRect in a given direction . Allows for keyboard navigation based on the relative visual location of the element .