From e358b16db683874a204f131ad4333486f4b538b5 Mon Sep 17 00:00:00 2001 From: Fritz Lekschas Date: Tue, 4 Mar 2025 16:42:10 -0500 Subject: [PATCH 1/2] feat: expose `isViewChanged` in `draw`, `drawing`, and `view` payload --- CHANGELOG.md | 4 ++++ README.md | 40 ++++++++++++++++++++-------------------- src/index.js | 1 + 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9652333..3e5b614 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.14.0 + +- Feat: expose a flag indicating a view change for events `draw`, `drawing`, and `view` + ## 1.13.2 - Fix: replace the even-odd rule based with the non-zero winding rule for `isPointInPolygon()` to correctly handle overlapping/looping selections. Previosuly points that would fall within the overlapping area would falsely be excluded from the selection instead of being included. diff --git a/README.md b/README.md index 48d1de3..6031b28 100644 --- a/README.md +++ b/README.md @@ -1051,26 +1051,26 @@ Render Regl draw instructions into a target canvas using the renderer. ### Events -| Name | Trigger | Payload | -| -------------------- | ------------------------------------------ | ---------------------------------- | -| init | when the scatter plot is initialized | `undefined` | -| destroy | when the scatter plot is destroyed | `undefined` | -| backgroundImageReady | when the background image was loaded | `undefined` | -| pointOver | when the mouse cursor is over a point | pointIndex | -| pointOut | when the mouse cursor moves out of a point | pointIndex | -| select | when points are selected | `{ points }` | -| deselect | when points are deselected | `undefined` | -| filter | when points are filtered | `{ points }` | -| unfilter | when the point filter is reset | `undefined` | -| view | when the view has changes | `{ camera, view, xScale, yScale }` | -| draw | when the plot was drawn | `{ camera, view, xScale, yScale }` | -| drawing | when the plot is being drawn | `{ camera, view, xScale, yScale }` | -| lassoStart | when the lasso selection has started | `undefined` | -| lassoExtend | when the lasso selection has extended | `{ coordinates }` | -| lassoEnd | when the lasso selection has ended | `{ coordinates }` | -| transitionStart | when points started to transition | `undefined` | -| transitionEnd | when points ended to transition | `createRegl(canvas)` | -| pointConnectionsDraw | when point connections were drawn | `undefined` | +| Name | Trigger | Payload | +| -------------------- | ------------------------------------------ | ------------------------------------------------- | +| init | when the scatter plot is initialized | `undefined` | +| destroy | when the scatter plot is destroyed | `undefined` | +| backgroundImageReady | when the background image was loaded | `undefined` | +| pointOver | when the mouse cursor is over a point | pointIndex | +| pointOut | when the mouse cursor moves out of a point | pointIndex | +| select | when points are selected | `{ points }` | +| deselect | when points are deselected | `undefined` | +| filter | when points are filtered | `{ points }` | +| unfilter | when the point filter is reset | `undefined` | +| view | when the view has changes | `{ camera, view, isViewChanged, xScale, yScale }` | +| draw | when the plot was drawn | `{ camera, view, isViewChanged, xScale, yScale }` | +| drawing | when the plot is being drawn | `{ camera, view, isViewChanged, xScale, yScale }` | +| lassoStart | when the lasso selection has started | `undefined` | +| lassoExtend | when the lasso selection has extended | `{ coordinates }` | +| lassoEnd | when the lasso selection has ended | `{ coordinates }` | +| transitionStart | when points started to transition | `undefined` | +| transitionEnd | when points ended to transition | `createRegl(canvas)` | +| pointConnectionsDraw | when point connections were drawn | `undefined` | ## Trouble Shooting diff --git a/src/index.js b/src/index.js index 0f095b7..6c6ecce 100644 --- a/src/index.js +++ b/src/index.js @@ -4467,6 +4467,7 @@ const createScatterplot = ( const renderView = { view: camera.view, + isViewChanged, camera, xScale, yScale, From f5a5274ae929caeb486fbae39feddcbb9a2953b5 Mon Sep 17 00:00:00 2001 From: Fritz Lekschas Date: Tue, 4 Mar 2025 16:43:02 -0500 Subject: [PATCH 2/2] fix: clean up worker URL after creation --- CHANGELOG.md | 1 + src/kdbush.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e5b614..806c805 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.14.0 - Feat: expose a flag indicating a view change for events `draw`, `drawing`, and `view` +- Fix: clean up worker URL after creation ## 1.13.2 diff --git a/src/kdbush.js b/src/kdbush.js index 4b7acbc..beb0414 100644 --- a/src/kdbush.js +++ b/src/kdbush.js @@ -16,13 +16,14 @@ const createWorker = (fn) => { `const createWorker = ${fnStr};` + 'createWorker();'; - return new Worker( - window.URL.createObjectURL( - new Blob([workerStr], { - type: 'text/javascript', - }), - ), - ); + const blob = new Blob([workerStr], { type: 'text/javascript' }); + const workerUrl = URL.createObjectURL(blob); + const worker = new Worker(workerUrl, { name: 'KDBush' }); + + // Clean up URL + URL.revokeObjectURL(workerUrl); + + return worker; }; /**