This file contains hidden or 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
| // find the element in the body with max z-index | |
| // adapted from this StackOverflow answer by Jimmy Chandra: | |
| // https://stackoverflow.com/a/1118216/470925 | |
| let max, maxVal = 0 | |
| document.querySelectorAll('body *').forEach(el => { | |
| // get position and zIndex style values for the element | |
| const {position, zIndex} = document.defaultView.getComputedStyle(el) | |
| // skip statically positioned elements | |
| if (position !== 'static') { | |
| // parse the string value of zIndex into an integer, defaulting to 1, |
This file contains hidden or 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
| /** | |
| * Clusters 2D points so each cluster can be enclosed in a circle of radius <= d. | |
| * Uses greedy agglomerative merging: repeatedly merge the pair of clusters whose | |
| * merged centroid distance is smallest, as long as the merged cluster's max | |
| * distance from its centroid <= d. | |
| * | |
| * @param {Array<[number, number]>} points - array of [x, y] pairs | |
| * @param {number} d - maximum allowed radius for any cluster | |
| * @returns {Array<Array<[number, number]>>} clusters | |
| */ |
OlderNewer