Skip to content

Commit

Permalink
Merge pull request w3c#79 from jihyerish/polyfill-fix-getDistance-bug
Browse files Browse the repository at this point in the history
Fix the bug in getDistance function
  • Loading branch information
Jihye Hong authored Jul 1, 2018
2 parents b7c5002 + 8611e35 commit 82f8940
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions polyfill/spatnav-heuristic.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ function focusNavigationHeuristics(spatnavPolyfillOptions) {
e.preventDefault();
navigate(dir);
}
startingPosition = null;
});

/*
* mouseclick EventListener :
* If the mouse click a point in the page, the point will be the starting point.
*/
* mouseclick EventListener :
* If the mouse click a point in the page, the point will be the starting point.
*/
document.addEventListener('click', function(e) {
startingPosition = {xPosition: e.clientX, yPosition: e.clientY};
});
Expand Down Expand Up @@ -124,7 +125,7 @@ function focusNavigationHeuristics(spatnavPolyfillOptions) {

if (Array.isArray(candidates) && candidates.length > 0) {
// 9
const bestCandidate = selectBestCandidate(eventTarget, candidates, dir, container);
const bestCandidate = selectBestCandidate(eventTarget, candidates, dir);
if (bestCandidate) {
// 10 & 11
focusingController(bestCandidate, dir);
Expand Down Expand Up @@ -261,7 +262,7 @@ function focusNavigationHeuristics(spatnavPolyfillOptions) {
if((isContainer(this) || this.nodeName === 'BODY') && !(this.nodeName === 'INPUT'))
bestCandidate = selectBestCandidateFromEdge(this, candidates_, dir);
else
bestCandidate = selectBestCandidate(this, candidates_, dir, container_);
bestCandidate = selectBestCandidate(this, candidates_, dir);
}

return bestCandidate;
Expand Down Expand Up @@ -854,8 +855,8 @@ function focusNavigationHeuristics(spatnavPolyfillOptions) {
* @param {SpatialNavigationDirection} direction
* @returns {distance} euclidian distance between two elements
*/
function getEntryAndExitPoints(rect1, rect2, dir) {
const points = {entryPoint:[0,0], exitPoint:[0,0]};
function getEntryAndExitPoints(dir = 'down', rect1, rect2) {
let points = {entryPoint:[0,0], exitPoint:[0,0]};

// Set direction
switch (dir) {
Expand Down

0 comments on commit 82f8940

Please sign in to comment.