Skip to content

Commit 6cfba83

Browse files
committed
[charts] Simplify zoom gesture jsdocs
1 parent 9eb61a2 commit 6cfba83

5 files changed

Lines changed: 30 additions & 34 deletions

File tree

packages/x-charts-pro/src/internals/plugins/zoomGestures/useDragGesture.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,30 @@ import { type ChartPoint, type GestureInstance, type PanGestureConfig } from './
77
export interface UseDragGestureOptions {
88
/** Whether the gesture is active. */
99
enabled: boolean;
10-
/** Pointer/keyboard gating forwarded to the interaction listener. */
10+
/** Pointer and keyboard gating for the gesture. */
1111
config?: PanGestureConfig;
1212
/**
13-
* Called once when a pan starts.
14-
* @param {PanEvent} event The original pan start event.
13+
* Called when the drag starts.
14+
* @param {PanEvent} event The pan start event.
1515
*/
1616
onPanStart?: (event: PanEvent) => void;
1717
/**
18-
* Throttled call of the pan event
19-
* @param {ChartPoint} delta The accumulated pixel delta since the last call.
20-
* @param {PanEvent} event The original pan event.
18+
* Called (rAF-throttled) on each drag update.
19+
* @param {ChartPoint} delta The pixel delta since the last call.
20+
* @param {PanEvent} event The pan event.
2121
*/
2222
onPan: (delta: ChartPoint, event: PanEvent) => void;
2323
/**
24-
* Called once when a pan ends.
25-
* @param {PanEvent} event The original pan end event.
24+
* Called when the drag ends.
25+
* @param {PanEvent} event The pan end event.
2626
*/
2727
onPanEnd?: (event: PanEvent) => void;
2828
}
2929

3030
/**
31-
* Generic drag-to-pan gesture binding, decoupled from any coordinate system.
31+
* Generic drag-to-pan gesture binding.
3232
*
33-
* It owns the listener lifecycle, the per-frame accumulation of the pixel delta, and
34-
* the rAF throttling. What to do with the delta is entirely up to `onPan` — cartesian
35-
* zoom translates an axis range, a map translates the projection, etc.
33+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
3634
*/
3735
export function useDragGesture(instance: GestureInstance, options: UseDragGestureOptions): void {
3836
const { enabled, config, onPanStart, onPan, onPanEnd } = options;

packages/x-charts-pro/src/internals/plugins/zoomGestures/useDragOnPressGesture.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@ import type { ChartPoint, GestureInstance, PanGestureConfig } from './zoomGestur
77
export interface UseDragOnPressGestureOptions {
88
/** Whether the gesture is active. */
99
enabled: boolean;
10-
/** Pointer/keyboard gating forwarded to the interaction listener. */
10+
/** Pointer and keyboard gating for the gesture. */
1111
config?: PanGestureConfig;
1212
/**
13-
* Called once when a pan starts.
14-
* @param {PanEvent} event The original pan start event.
13+
* Called when the drag starts.
14+
* @param {PanEvent} event The pan start event.
1515
*/
1616
onPanStart?: (event: PanEvent) => void;
1717
/**
18-
* Throttled call of the pan event
19-
* @param {ChartPoint} delta The accumulated pixel delta since the last call.
20-
* @param {PanEvent} event The original pan event.
18+
* Called (rAF-throttled) on each drag update.
19+
* @param {ChartPoint} delta The pixel delta since the last call.
20+
* @param {PanEvent} event The pan event.
2121
*/
2222
onPan: (delta: ChartPoint, event: PanEvent) => void;
2323
/**
24-
* Called once when a pan ends.
25-
* @param {PanEvent} event The original pan end event.
24+
* Called when the drag ends.
25+
* @param {PanEvent} event The pan end event.
2626
*/
2727
onPanEnd?: (event: PanEvent) => void;
2828
}
2929

3030
/**
31-
* Generic drag-to-pan gesture binding.
31+
* Generic press-and-drag-to-pan gesture binding.
3232
*
33-
* It owns the listener lifecycle, and allows the user to create their own interactions by providing the delta change of the interaction.
33+
* It owns the listener lifecycle, and lets you create your own interactions by providing the delta change of the interaction.
3434
*/
3535
export function useDragOnPressGesture(
3636
instance: GestureInstance,

packages/x-charts-pro/src/internals/plugins/zoomGestures/usePinchGesture.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ export interface UsePinchGestureOptions {
1414
* Called (rAF-throttled) on each pinch update.
1515
*
1616
* @param {ChartPoint} point The pinch centroid, in SVG coordinates.
17-
* @param {number} deltaScale The incremental scale change for this update.
17+
* @param {number} deltaScale The scale change since the last call.
1818
* @param {number} direction `> 0` when zooming in, `< 0` when zooming out.
1919
*/
2020
onPinch: (point: ChartPoint, deltaScale: number, direction: number) => void;
2121
}
2222

2323
/**
24-
* Generic pinch gesture binding. Forwards the centroid and scale delta to `onPinch`.
24+
* Generic pinch gesture binding.
25+
*
26+
* It owns the listener lifecycle, and lets you create your own interactions from the centroid and scale delta it forwards to `onPinch`.
2527
*/
2628
export function usePinchGesture(instance: GestureInstance, options: UsePinchGestureOptions): void {
2729
const { enabled, requiredKeys, onPinch } = options;

packages/x-charts-pro/src/internals/plugins/zoomGestures/useWheelGesture.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ export interface UseWheelGestureOptions {
1111
/** Keys that must be held for the wheel to trigger the gesture. */
1212
requiredKeys?: KeyboardKey[];
1313
/**
14-
* Called on each wheel tick that lands inside the drawing area.
14+
* Called on each wheel tick inside the drawing area.
1515
*
1616
* @param {ChartPoint} point The wheel focal point, in SVG coordinates.
17-
* @param {WheelEvent} event The raw `WheelEvent`.
17+
* @param {WheelEvent} event The `WheelEvent`.
1818
*/
1919
onWheel: (point: ChartPoint, event: WheelEvent) => void;
2020
}
2121

2222
/**
23-
* Generic wheel gesture binding. Handles the "started outside the chart" guard and
24-
* `preventDefault`, then forwards the focal point and wheel delta to `onWheel`.
23+
* Generic wheel gesture binding.
24+
*
25+
* It owns the listener lifecycle, and lets you create your own interactions from the focal point and wheel event it forwards to `onWheel`.
2526
*/
2627
export function useWheelGesture(instance: GestureInstance, options: UseWheelGestureOptions): void {
2728
const { enabled, requiredKeys, onWheel } = options;

packages/x-charts-pro/src/internals/plugins/zoomGestures/zoomGestures.types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import type { UseChartInteractionListenerInstance } from '@mui/x-charts/internal
44

55
/**
66
* The minimal slice of a chart instance required to bind zoom/pan gestures.
7-
*
8-
* Every method here is provided by core plugins (`useChartInteractionListener`,
9-
* `useChartDimensions`, `useChartElementRef`), so any chart — cartesian or not —
10-
* can consume these gesture hooks.
117
*/
128
export interface GestureInstance {
139
chartsLayerContainerRef: React.RefObject<HTMLDivElement | null>;
@@ -17,8 +13,7 @@ export interface GestureInstance {
1713
}
1814

1915
/**
20-
* Pointer/keyboard gating for a pan gesture, mirroring the options accepted by
21-
* `instance.updateZoomInteractionListeners('zoomPan', …)`.
16+
* Pointer and keyboard gating for a pan gesture.
2217
*/
2318
export interface PanGestureConfig {
2419
requiredKeys?: KeyboardKey[];

0 commit comments

Comments
 (0)