diff --git a/src/_components/QuadTree.html.svelte b/src/_components/QuadTree.html.svelte index eb754b00..732a3e42 100644 --- a/src/_components/QuadTree.html.svelte +++ b/src/_components/QuadTree.html.svelte @@ -14,10 +14,10 @@ let found = {}; let e = {}; - /** @type {string} [x='x'] – The dimension to search across when moving the mouse left and right. */ + /** @type {'x'|'y'} [x='x'] – The dimension to search across when moving the mouse left and right. */ export let x = 'x'; - /** @type {string} [y='y'] – The dimension to search across when moving the mouse up and down. */ + /** @type {'x'|'y'} [y='y'] – The dimension to search across when moving the mouse up and down. */ export let y = 'y'; /** @type {number|undefined} [searchRadius] – The number of pixels to search around the mouse's location. This is the third argument passed to [`quadtree.find`](https://github.com/d3/d3-quadtree#quadtree_find) and by default a value of `undefined` means an unlimited range. */ @@ -29,11 +29,12 @@ $: xGetter = x === 'x' ? $xGet : $yGet; $: yGetter = y === 'y' ? $yGet : $xGet; + /** @param {MouseEvent} evt */ function findItem(evt) { e = evt; - const xLayerKey = `layer${x.toUpperCase()}`; - const yLayerKey = `layer${y.toUpperCase()}`; + const xLayerKey = /** @type {'layerX'|'layerY'} */ (`layer${x.toUpperCase()}`); + const yLayerKey = /** @type {'layerX'|'layerY'}*/ (`layer${y.toUpperCase()}`); found = finder.find(evt[xLayerKey], evt[yLayerKey], searchRadius) || {}; visible = Object.keys(found).length > 0; diff --git a/src/_components/QuadTree.percent-range.html.svelte b/src/_components/QuadTree.percent-range.html.svelte index 4262633b..9d7494a6 100644 --- a/src/_components/QuadTree.percent-range.html.svelte +++ b/src/_components/QuadTree.percent-range.html.svelte @@ -14,10 +14,10 @@ let found = {}; let e = {}; - /** @type {string} [x='x'] - The dimension to search across when moving the mouse left and right. */ + /** @type {'x'|'y'} [x='x'] - The dimension to search across when moving the mouse left and right. */ export let x = 'x'; - /** @type {string} [y='y'] - The dimension to search across when moving the mouse up and down. */ + /** @type {'x'|'y'} [y='y'] - The dimension to search across when moving the mouse up and down. */ export let y = 'y'; /** @type {number|undefined} [searchRadius] - The number of pixels to search around the mouse's location. This is the third argument passed to [`quadtree.find`](https://github.com/d3/d3-quadtree#quadtree_find) and by default a value of `undefined` means an unlimited range. */ @@ -29,11 +29,12 @@ $: xGetter = x === 'x' ? $xGet : $yGet; $: yGetter = y === 'y' ? $yGet : $xGet; + /** @param {MouseEvent} evt*/ function findItem(evt) { e = evt; - const xLayerKey = `layer${x.toUpperCase()}`; - const yLayerKey = `layer${y.toUpperCase()}`; + const xLayerKey = /** @type {'layerX'|'layerY'} */ (`layer${x.toUpperCase()}`); + const yLayerKey = /** @type {'layerX'|'layerY'}*/ (`layer${y.toUpperCase()}`); const xLayerVal = (evt[xLayerKey] / (x === 'x' ? $width : $height)) * 100; const yLayerVal = (evt[yLayerKey] / (y === 'y' ? $height : $width)) * 100;