Skip to content

Commit

Permalink
fix: expose lassoLongPressIndicatorParentElement (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
flekschas authored Dec 13, 2024
1 parent 0b1a61d commit 6259d9a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.11.4

- Fix: allow setting the lasso long press indicator parent element

## 1.11.3

- Fix: catch another edge case where `zoomToOrigin` was unsetting the camera fixed state
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ can be read and written via [`scatterplot.get()`](#scatterplot.get) and [`scatte
| lassoInitiator | boolean | `false` | | `true` | `false` |
| lassoInitiatorElement | object | the lasso dom element | | `false` | `false` |
| lassoInitiatorParentElement | object | `document.body` | | `true` | `false` |
| lassoLongPressIndicatorParentElement | object | `document.body` | | `true` | `false` |
| lassoOnLongPress | boolean | `false` | | `true` | `false` |
| lassoLongPressTime | int | `750` | | `true` | `false` |
| lassoLongPressAfterEffectTime | int | `500` | | `true` | `false` |
Expand Down
23 changes: 22 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ const createScatterplot = (
lassoClearEvent = DEFAULT_LASSO_CLEAR_EVENT,
lassoInitiator = DEFAULT_LASSO_INITIATOR,
lassoInitiatorParentElement = document.body,
lassoLongPressIndicatorParentElement = document.body,
lassoOnLongPress = DEFAULT_LASSO_ON_LONG_PRESS,
lassoLongPressTime = DEFAULT_LASSO_LONG_PRESS_TIME,
lassoLongPressAfterEffectTime = DEFAULT_LASSO_LONG_PRESS_AFTER_EFFECT_TIME,
Expand Down Expand Up @@ -909,6 +910,7 @@ const createScatterplot = (
onEnd: lassoEnd,
enableInitiator: lassoInitiator,
initiatorParentElement: lassoInitiatorParentElement,
longPressIndicatorParentElement: lassoLongPressIndicatorParentElement,
pointNorm: ([x, y]) => getScatterGlPos(getNdcX(x), getNdcY(y)),
});

Expand Down Expand Up @@ -2994,7 +2996,15 @@ const createScatterplot = (
lassoInitiatorParentElement = newLassoInitiatorParentElement;

lassoManager.set({
startInitiatorParentElement: lassoInitiatorParentElement,
initiatorParentElement: lassoInitiatorParentElement,
});
};

const setLassoLongPressIndicatorParentElement = (newParentElement) => {
lassoLongPressIndicatorParentElement = newParentElement;

lassoManager.set({
longPressIndicatorParentElement: lassoLongPressIndicatorParentElement,
});
};

Expand Down Expand Up @@ -3362,6 +3372,11 @@ const createScatterplot = (
if (property === 'lassoInitiatorParentElement') {
return lassoInitiatorParentElement;
}

if (property === 'lassoLongPressIndicatorParentElement') {
return lassoLongPressIndicatorParentElement;
}

if (property === 'keyMap') {
return { ...keyMap };
}
Expand Down Expand Up @@ -3757,6 +3772,12 @@ const createScatterplot = (
setLassoInitiatorParentElement(properties.lassoInitiatorParentElement);
}

if (properties.lassoLongPressIndicatorParentElement !== undefined) {
setLassoLongPressIndicatorParentElement(
properties.lassoLongPressIndicatorParentElement,
);
}

if (properties.lassoOnLongPress !== undefined) {
setLassoOnLongPress(properties.lassoOnLongPress);
}
Expand Down
1 change: 1 addition & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export type Properties = {
syncEvents: boolean;
version: string;
lassoInitiatorElement: HTMLElement;
lassoLongPressIndicatorParentElement: HTMLElement;
camera: Camera2D;
performanceMode: boolean;
opacityByDensityDebounceTime: number;
Expand Down

0 comments on commit 6259d9a

Please sign in to comment.