Skip to content

Commit 04bccc4

Browse files
committed
cleaner pool.frame
1 parent 97dd4e2 commit 04bccc4

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/interactions/pointer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
3333
// the pointer (e.g., tips); only the closest point is shown.
3434
let state = states.get(svg);
3535
if (!state) {
36-
state = {sticky: false, roots: [], renders: [], pool: this.pool ? new Map() : null};
36+
state = {sticky: false, roots: [], renders: [], pool: this.pool ? {map: new Map()} : null};
3737
states.set(svg, state);
3838
}
3939

@@ -63,7 +63,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
6363
let facetPools = state.facetPools;
6464
if (!facetPools) state.facetPools = facetPools = new Map();
6565
facetPool = facetPools.get(this);
66-
if (!facetPool) facetPools.set(this, (facetPool = new Map()));
66+
if (!facetPool) facetPools.set(this, (facetPool = {map: new Map()}));
6767
}
6868

6969
// The order of precedence for the pointer position is: px & py; the
@@ -86,13 +86,13 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
8686
function update(ii, ri) {
8787
if (!pool) return void render(ii);
8888
if (ii == null) render(ii);
89-
pool.set(renderIndex, {ii, ri, render});
89+
pool.map.set(renderIndex, {ii, ri, render});
9090
if (pool.frame !== undefined) cancelAnimationFrame(pool.frame);
9191
pool.frame = requestAnimationFrame(() => {
9292
pool.frame = undefined;
9393
let best = null;
94-
for (const [, c] of pool) if (!best || c.ri < best.ri) best = c;
95-
for (const [, c] of pool) c.render(c === best ? c.ii : null);
94+
for (const c of pool.map.values()) if (!best || c.ri < best.ri) best = c;
95+
for (const c of pool.map.values()) c.render(c === best ? c.ii : null);
9696
});
9797
}
9898

@@ -124,7 +124,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
124124

125125
// Dispatch the value. When simultaneously exiting this facet and
126126
// entering a new one, prioritize the entering facet.
127-
if (!(i == null && facetPool?.size > 1)) {
127+
if (!(i == null && facetPool?.map.size > 1)) {
128128
const value = i == null ? null : isArray(data) ? data[i] : data.get(i);
129129
context.dispatchValue(value);
130130
}

0 commit comments

Comments
 (0)