Internally the library creates an array of objects during distance calculations. These objects contain a reference to an element and the calculated distance.
However, after all comparisons are finished, the extra information is thrown away and only elements are returned.
It would be good to provide a way to return all the information, so that consumers don't have to recalculate the distance themselves. Even the demo page for this library has to duplicate the distance calculation.
Extra information could also be added, such as a basic direction ("up", "right", etc.) and/or a specific angle of direction to the element.
Internally the library creates an array of objects during distance calculations. These objects contain a reference to an element and the calculated distance. However, after all comparisons are finished, the extra information is thrown away and only elements are returned.
It would be good to provide a way to return all the information, so that consumers don't have to recalculate the distance themselves. Even the demo page for this library has to duplicate the distance calculation.
Extra information could also be added, such as a basic direction ("up", "right", etc.) and/or a specific angle of direction to the element.