Skip to content

Commit

Permalink
feat: expose if view has changed (#218)
Browse files Browse the repository at this point in the history
* feat: expose `isViewChanged` in `draw`, `drawing`, and `view` payload

* fix: clean up worker URL after creation
  • Loading branch information
flekschas authored Mar 4, 2025
1 parent 4a26470 commit aa70130
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 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

- 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.
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4467,6 +4467,7 @@ const createScatterplot = (

const renderView = {
view: camera.view,
isViewChanged,
camera,
xScale,
yScale,
Expand Down
15 changes: 8 additions & 7 deletions src/kdbush.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down

0 comments on commit aa70130

Please sign in to comment.