-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove whitespaces and editor changes
- Loading branch information
1 parent
9c97b90
commit 83d10fb
Showing
5 changed files
with
19 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
.idea | ||
node_modules | ||
example/bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
/** | ||
* Given a node, get everything needed to calculate its boundaries | ||
* @param {HTMLElement} node | ||
* @param {HTMLElement} node | ||
* @return {Object} | ||
*/ | ||
export default node => { | ||
const rect = node.getBoundingClientRect(); | ||
|
||
return { | ||
top: rect.top + document.body.scrollTop, | ||
left: rect.left + document.body.scrollLeft, | ||
top: rect.top+document.body.scrollTop, | ||
left: rect.left+document.body.scrollLeft, | ||
offsetWidth: node.offsetWidth, | ||
offsetHeight: node.offsetHeight | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ export { | |
SelectableGroup, | ||
createSelectable, | ||
isNodeIn, | ||
nodeInRoot | ||
}; | ||
nodeInRoot, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
const isNodeIn = (node, predicate) => { | ||
if (typeof predicate !== 'function') { | ||
throw new Error('isNodeIn second parameter must be a function'); | ||
} | ||
if (typeof predicate !== 'function') { | ||
throw new Error('isNodeIn second parameter must be a function'); | ||
} | ||
|
||
let currentNode = node; | ||
while (currentNode) { | ||
if (predicate(currentNode)) { | ||
return true; | ||
} | ||
currentNode = currentNode.parentNode; | ||
} | ||
|
||
let currentNode = node; | ||
while (currentNode) { | ||
if (predicate(currentNode)) { | ||
return true; | ||
} | ||
currentNode = currentNode.parentNode; | ||
} | ||
|
||
return false; | ||
return false; | ||
}; | ||
|
||
export default isNodeIn; |