@mui/x-charts-pro 8.0.0-alpha.7 → 8.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChartPro/BarChartPro.d.ts +2 -2
- package/BarChartPro/BarChartPro.js +55 -19
- package/CHANGELOG.md +115 -0
- package/ChartContainerPro/ChartContainerPro.d.ts +32 -4
- package/ChartContainerPro/ChartContainerPro.js +53 -18
- package/ChartContainerPro/useChartContainerProProps.d.ts +5 -5
- package/ChartContainerPro/useChartContainerProProps.js +11 -5
- package/Heatmap/Heatmap.js +28 -2
- package/Heatmap/HeatmapTooltip.js +6 -4
- package/Heatmap/extremums.d.ts +2 -2
- package/Heatmap/formatter.d.ts +2 -2
- package/Heatmap/formatter.js +2 -1
- package/Heatmap/plugin.d.ts +2 -2
- package/Heatmap/plugin.js +1 -2
- package/LineChartPro/LineChartPro.d.ts +2 -2
- package/LineChartPro/LineChartPro.js +57 -25
- package/ScatterChartPro/ScatterChartPro.d.ts +2 -2
- package/ScatterChartPro/ScatterChartPro.js +37 -28
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/zoom/index.d.ts +1 -0
- package/hooks/zoom/index.js +1 -0
- package/hooks/zoom/useIsZoomInteracting.d.ts +6 -0
- package/hooks/zoom/useIsZoomInteracting.js +14 -0
- package/index.d.ts +0 -1
- package/index.js +2 -5
- package/internals/plugins/allPlugins.d.ts +10 -0
- package/internals/plugins/allPlugins.js +5 -0
- package/internals/plugins/useChartProZoom/defaultizeZoom.d.ts +2 -0
- package/internals/plugins/useChartProZoom/defaultizeZoom.js +25 -0
- package/internals/plugins/useChartProZoom/index.d.ts +3 -0
- package/internals/plugins/useChartProZoom/index.js +3 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.d.ts +3 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.js +324 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +149 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +6 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +54 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.utils.d.ts +45 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.utils.js +126 -0
- package/internals/plugins/useChartProZoom/zoom.types.d.ts +53 -0
- package/internals/utils/releaseInfo.js +1 -1
- package/models/index.d.ts +1 -0
- package/models/index.js +2 -1
- package/modern/BarChartPro/BarChartPro.js +55 -19
- package/modern/ChartContainerPro/ChartContainerPro.js +53 -18
- package/modern/ChartContainerPro/useChartContainerProProps.js +11 -5
- package/modern/Heatmap/Heatmap.js +28 -2
- package/modern/Heatmap/HeatmapTooltip.js +6 -4
- package/modern/Heatmap/formatter.js +2 -1
- package/modern/Heatmap/plugin.js +1 -2
- package/modern/LineChartPro/LineChartPro.js +57 -25
- package/modern/ScatterChartPro/ScatterChartPro.js +37 -28
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/zoom/index.js +1 -0
- package/modern/hooks/zoom/useIsZoomInteracting.js +14 -0
- package/modern/index.js +2 -5
- package/modern/internals/plugins/allPlugins.js +5 -0
- package/modern/internals/plugins/useChartProZoom/defaultizeZoom.js +25 -0
- package/modern/internals/plugins/useChartProZoom/index.js +3 -0
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.js +324 -0
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +6 -0
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.types.js +1 -0
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.utils.js +126 -0
- package/modern/internals/plugins/useChartProZoom/zoom.types.js +1 -0
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/modern/models/index.js +2 -1
- package/node/BarChartPro/BarChartPro.js +55 -19
- package/node/ChartContainerPro/ChartContainerPro.js +53 -18
- package/node/ChartContainerPro/useChartContainerProProps.js +11 -5
- package/node/Heatmap/Heatmap.js +28 -2
- package/node/Heatmap/HeatmapTooltip.js +4 -2
- package/node/Heatmap/formatter.js +2 -1
- package/node/Heatmap/plugin.js +1 -2
- package/node/LineChartPro/LineChartPro.js +57 -25
- package/node/ScatterChartPro/ScatterChartPro.js +36 -27
- package/node/hooks/index.js +16 -1
- package/node/{context/CartesianProviderPro → hooks/zoom}/index.js +4 -4
- package/node/hooks/zoom/useIsZoomInteracting.js +19 -0
- package/node/index.js +1 -12
- package/node/internals/plugins/allPlugins.js +11 -0
- package/node/internals/plugins/useChartProZoom/defaultizeZoom.js +33 -0
- package/node/internals/plugins/useChartProZoom/index.js +38 -0
- package/node/internals/plugins/useChartProZoom/useChartProZoom.js +331 -0
- package/node/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +13 -0
- package/node/internals/plugins/useChartProZoom/useChartProZoom.utils.js +140 -0
- package/node/internals/plugins/useChartProZoom/zoom.types.js +5 -0
- package/node/internals/utils/releaseInfo.js +1 -1
- package/package.json +5 -5
- package/typeOverloads/modules.d.ts +8 -1
- package/context/CartesianProviderPro/CartesianProviderPro.d.ts +0 -6
- package/context/CartesianProviderPro/CartesianProviderPro.js +0 -89
- package/context/CartesianProviderPro/createAxisFilterMapper.d.ts +0 -13
- package/context/CartesianProviderPro/createAxisFilterMapper.js +0 -60
- package/context/CartesianProviderPro/index.d.ts +0 -1
- package/context/CartesianProviderPro/index.js +0 -1
- package/context/ChartDataProviderPro/ChartDataProviderPro.d.ts +0 -7
- package/context/ChartDataProviderPro/ChartDataProviderPro.js +0 -50
- package/context/ChartDataProviderPro/index.d.ts +0 -1
- package/context/ChartDataProviderPro/index.js +0 -1
- package/context/ChartDataProviderPro/useChartDataProviderProProps.d.ts +0 -14
- package/context/ChartDataProviderPro/useChartDataProviderProProps.js +0 -43
- package/context/ZoomProvider/Zoom.types.d.ts +0 -144
- package/context/ZoomProvider/ZoomContext.d.ts +0 -4
- package/context/ZoomProvider/ZoomContext.js +0 -16
- package/context/ZoomProvider/ZoomProvider.d.ts +0 -3
- package/context/ZoomProvider/ZoomProvider.js +0 -56
- package/context/ZoomProvider/ZoomSetup.d.ts +0 -9
- package/context/ZoomProvider/ZoomSetup.js +0 -16
- package/context/ZoomProvider/defaultizeZoom.d.ts +0 -2
- package/context/ZoomProvider/defaultizeZoom.js +0 -32
- package/context/ZoomProvider/index.d.ts +0 -3
- package/context/ZoomProvider/index.js +0 -3
- package/context/ZoomProvider/initializeZoomData.d.ts +0 -6
- package/context/ZoomProvider/initializeZoomData.js +0 -13
- package/context/ZoomProvider/useSetupPan.d.ts +0 -1
- package/context/ZoomProvider/useSetupPan.js +0 -106
- package/context/ZoomProvider/useSetupZoom.d.ts +0 -1
- package/context/ZoomProvider/useSetupZoom.js +0 -274
- package/context/ZoomProvider/useZoom.d.ts +0 -7
- package/context/ZoomProvider/useZoom.js +0 -19
- package/context/index.d.ts +0 -3
- package/context/index.js +0 -5
- package/context/package.json +0 -6
- package/modern/context/CartesianProviderPro/CartesianProviderPro.js +0 -89
- package/modern/context/CartesianProviderPro/createAxisFilterMapper.js +0 -60
- package/modern/context/CartesianProviderPro/index.js +0 -1
- package/modern/context/ChartDataProviderPro/ChartDataProviderPro.js +0 -50
- package/modern/context/ChartDataProviderPro/index.js +0 -1
- package/modern/context/ChartDataProviderPro/useChartDataProviderProProps.js +0 -43
- package/modern/context/ZoomProvider/ZoomContext.js +0 -16
- package/modern/context/ZoomProvider/ZoomProvider.js +0 -56
- package/modern/context/ZoomProvider/ZoomSetup.js +0 -16
- package/modern/context/ZoomProvider/defaultizeZoom.js +0 -32
- package/modern/context/ZoomProvider/index.js +0 -3
- package/modern/context/ZoomProvider/initializeZoomData.js +0 -13
- package/modern/context/ZoomProvider/useSetupPan.js +0 -106
- package/modern/context/ZoomProvider/useSetupZoom.js +0 -274
- package/modern/context/ZoomProvider/useZoom.js +0 -19
- package/modern/context/index.js +0 -5
- package/node/context/CartesianProviderPro/CartesianProviderPro.js +0 -95
- package/node/context/CartesianProviderPro/createAxisFilterMapper.js +0 -68
- package/node/context/ChartDataProviderPro/ChartDataProviderPro.js +0 -56
- package/node/context/ChartDataProviderPro/index.js +0 -16
- package/node/context/ChartDataProviderPro/useChartDataProviderProProps.js +0 -50
- package/node/context/ZoomProvider/ZoomContext.js +0 -23
- package/node/context/ZoomProvider/ZoomProvider.js +0 -63
- package/node/context/ZoomProvider/ZoomSetup.js +0 -20
- package/node/context/ZoomProvider/defaultizeZoom.js +0 -40
- package/node/context/ZoomProvider/index.js +0 -38
- package/node/context/ZoomProvider/initializeZoomData.js +0 -20
- package/node/context/ZoomProvider/useSetupPan.js +0 -114
- package/node/context/ZoomProvider/useSetupZoom.js +0 -281
- package/node/context/ZoomProvider/useZoom.js +0 -25
- package/node/context/index.js +0 -27
- /package/{context/ZoomProvider/Zoom.types.js → internals/plugins/useChartProZoom/useChartProZoom.types.js} +0 -0
- /package/{modern/context/ZoomProvider/Zoom.types.js → internals/plugins/useChartProZoom/zoom.types.js} +0 -0
- /package/node/{context/ZoomProvider/Zoom.types.js → internals/plugins/useChartProZoom/useChartProZoom.types.js} +0 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useSelector, getSVGPoint, selectorChartDrawingArea } from '@mui/x-charts/internals';
|
|
6
|
+
import { defaultizeZoom } from "./defaultizeZoom.js";
|
|
7
|
+
import { getDiff, getHorizontalCenterRatio, getPinchScaleRatio, getVerticalCenterRatio, getWheelScaleRatio, isSpanValid, preventDefault, zoomAtPoint } from "./useChartProZoom.utils.js";
|
|
8
|
+
import { selectorChartZoomOptionsLookup } from "./useChartProZoom.selectors.js";
|
|
9
|
+
|
|
10
|
+
// It is helpful to avoid the need to provide the possibly auto-generated id for each axis.
|
|
11
|
+
function initializeZoomData(options) {
|
|
12
|
+
return Object.values(options).map(({
|
|
13
|
+
axisId,
|
|
14
|
+
minStart: start,
|
|
15
|
+
maxEnd: end
|
|
16
|
+
}) => ({
|
|
17
|
+
axisId,
|
|
18
|
+
start,
|
|
19
|
+
end
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
export const useChartProZoom = ({
|
|
23
|
+
store,
|
|
24
|
+
instance,
|
|
25
|
+
svgRef,
|
|
26
|
+
params
|
|
27
|
+
}) => {
|
|
28
|
+
const drawingArea = useSelector(store, selectorChartDrawingArea);
|
|
29
|
+
const optionsLookup = useSelector(store, selectorChartZoomOptionsLookup);
|
|
30
|
+
const isZoomEnabled = Object.keys(optionsLookup).length > 0;
|
|
31
|
+
|
|
32
|
+
// Add events
|
|
33
|
+
const panningEventCacheRef = React.useRef([]);
|
|
34
|
+
const zoomEventCacheRef = React.useRef([]);
|
|
35
|
+
const eventPrevDiff = React.useRef(0);
|
|
36
|
+
const interactionTimeoutRef = React.useRef(undefined);
|
|
37
|
+
const setIsInteracting = React.useCallback(isInteracting => {
|
|
38
|
+
store.update(prev => _extends({}, prev, {
|
|
39
|
+
zoom: _extends({}, prev.zoom, {
|
|
40
|
+
isInteracting
|
|
41
|
+
})
|
|
42
|
+
}));
|
|
43
|
+
}, [store]);
|
|
44
|
+
const setZoomDataCallback = React.useCallback(zoomData => {
|
|
45
|
+
store.update(prevState => {
|
|
46
|
+
const newZoomData = typeof zoomData === 'function' ? zoomData(prevState.zoom.zoomData) : zoomData;
|
|
47
|
+
params.onZoomChange?.(newZoomData);
|
|
48
|
+
return _extends({}, prevState, {
|
|
49
|
+
zoom: _extends({}, prevState.zoom, {
|
|
50
|
+
zoomData: newZoomData
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}, [params, store]);
|
|
55
|
+
|
|
56
|
+
// Add event for chart panning
|
|
57
|
+
const isPanEnabled = React.useMemo(() => Object.values(optionsLookup).some(v => v.panning) || false, [optionsLookup]);
|
|
58
|
+
const isDraggingRef = React.useRef(false);
|
|
59
|
+
const touchStartRef = React.useRef(null);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
const element = svgRef.current;
|
|
62
|
+
if (element === null || !isPanEnabled) {
|
|
63
|
+
return () => {};
|
|
64
|
+
}
|
|
65
|
+
const handlePan = event => {
|
|
66
|
+
if (element === null || !isDraggingRef.current || panningEventCacheRef.current.length > 1) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (touchStartRef.current == null) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const point = getSVGPoint(element, event);
|
|
73
|
+
const movementX = point.x - touchStartRef.current.x;
|
|
74
|
+
const movementY = (point.y - touchStartRef.current.y) * -1;
|
|
75
|
+
const newZoomData = touchStartRef.current.zoomData.map(zoom => {
|
|
76
|
+
const options = optionsLookup[zoom.axisId];
|
|
77
|
+
if (!options || !options.panning) {
|
|
78
|
+
return zoom;
|
|
79
|
+
}
|
|
80
|
+
const min = zoom.start;
|
|
81
|
+
const max = zoom.end;
|
|
82
|
+
const span = max - min;
|
|
83
|
+
const MIN_PERCENT = options.minStart;
|
|
84
|
+
const MAX_PERCENT = options.maxEnd;
|
|
85
|
+
const movement = options.axisDirection === 'x' ? movementX : movementY;
|
|
86
|
+
const dimension = options.axisDirection === 'x' ? drawingArea.width : drawingArea.height;
|
|
87
|
+
let newMinPercent = min - movement / dimension * span;
|
|
88
|
+
let newMaxPercent = max - movement / dimension * span;
|
|
89
|
+
if (newMinPercent < MIN_PERCENT) {
|
|
90
|
+
newMinPercent = MIN_PERCENT;
|
|
91
|
+
newMaxPercent = newMinPercent + span;
|
|
92
|
+
}
|
|
93
|
+
if (newMaxPercent > MAX_PERCENT) {
|
|
94
|
+
newMaxPercent = MAX_PERCENT;
|
|
95
|
+
newMinPercent = newMaxPercent - span;
|
|
96
|
+
}
|
|
97
|
+
if (newMinPercent < MIN_PERCENT || newMaxPercent > MAX_PERCENT || span < options.minSpan || span > options.maxSpan) {
|
|
98
|
+
return zoom;
|
|
99
|
+
}
|
|
100
|
+
return _extends({}, zoom, {
|
|
101
|
+
start: newMinPercent,
|
|
102
|
+
end: newMaxPercent
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
setZoomDataCallback(newZoomData);
|
|
106
|
+
};
|
|
107
|
+
const handleDown = event => {
|
|
108
|
+
panningEventCacheRef.current.push(event);
|
|
109
|
+
const point = getSVGPoint(element, event);
|
|
110
|
+
if (!instance.isPointInside(point)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// If there is only one pointer, prevent selecting text
|
|
114
|
+
if (panningEventCacheRef.current.length === 1) {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
}
|
|
117
|
+
isDraggingRef.current = true;
|
|
118
|
+
setIsInteracting(true);
|
|
119
|
+
touchStartRef.current = {
|
|
120
|
+
x: point.x,
|
|
121
|
+
y: point.y,
|
|
122
|
+
zoomData: store.getSnapshot().zoom.zoomData
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const handleUp = event => {
|
|
126
|
+
panningEventCacheRef.current.splice(panningEventCacheRef.current.findIndex(cachedEvent => cachedEvent.pointerId === event.pointerId), 1);
|
|
127
|
+
setIsInteracting(false);
|
|
128
|
+
isDraggingRef.current = false;
|
|
129
|
+
touchStartRef.current = null;
|
|
130
|
+
};
|
|
131
|
+
element.addEventListener('pointerdown', handleDown);
|
|
132
|
+
document.addEventListener('pointermove', handlePan);
|
|
133
|
+
document.addEventListener('pointerup', handleUp);
|
|
134
|
+
document.addEventListener('pointercancel', handleUp);
|
|
135
|
+
document.addEventListener('pointerleave', handleUp);
|
|
136
|
+
return () => {
|
|
137
|
+
element.removeEventListener('pointerdown', handleDown);
|
|
138
|
+
document.removeEventListener('pointermove', handlePan);
|
|
139
|
+
document.removeEventListener('pointerup', handleUp);
|
|
140
|
+
document.removeEventListener('pointercancel', handleUp);
|
|
141
|
+
document.removeEventListener('pointerleave', handleUp);
|
|
142
|
+
};
|
|
143
|
+
}, [instance, svgRef, isDraggingRef, setIsInteracting, isPanEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store]);
|
|
144
|
+
|
|
145
|
+
// Add event for chart zoom in/out
|
|
146
|
+
React.useEffect(() => {
|
|
147
|
+
const element = svgRef.current;
|
|
148
|
+
if (element === null || !isZoomEnabled) {
|
|
149
|
+
return () => {};
|
|
150
|
+
}
|
|
151
|
+
const wheelHandler = event => {
|
|
152
|
+
if (element === null) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const point = getSVGPoint(element, event);
|
|
156
|
+
if (!instance.isPointInside(point)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
if (interactionTimeoutRef.current) {
|
|
161
|
+
clearTimeout(interactionTimeoutRef.current);
|
|
162
|
+
}
|
|
163
|
+
setIsInteracting(true);
|
|
164
|
+
// Debounce transition to `isInteractive=false`.
|
|
165
|
+
// Useful because wheel events don't have an "end" event.
|
|
166
|
+
interactionTimeoutRef.current = window.setTimeout(() => {
|
|
167
|
+
setIsInteracting(false);
|
|
168
|
+
}, 166);
|
|
169
|
+
setZoomDataCallback(prevZoomData => {
|
|
170
|
+
return prevZoomData.map(zoom => {
|
|
171
|
+
const option = optionsLookup[zoom.axisId];
|
|
172
|
+
if (!option) {
|
|
173
|
+
return zoom;
|
|
174
|
+
}
|
|
175
|
+
const centerRatio = option.axisDirection === 'x' ? getHorizontalCenterRatio(point, drawingArea) : getVerticalCenterRatio(point, drawingArea);
|
|
176
|
+
const {
|
|
177
|
+
scaleRatio,
|
|
178
|
+
isZoomIn
|
|
179
|
+
} = getWheelScaleRatio(event, option.step);
|
|
180
|
+
const [newMinRange, newMaxRange] = zoomAtPoint(centerRatio, scaleRatio, zoom, option);
|
|
181
|
+
if (!isSpanValid(newMinRange, newMaxRange, isZoomIn, option)) {
|
|
182
|
+
return zoom;
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
axisId: zoom.axisId,
|
|
186
|
+
start: newMinRange,
|
|
187
|
+
end: newMaxRange
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
function pointerDownHandler(event) {
|
|
193
|
+
zoomEventCacheRef.current.push(event);
|
|
194
|
+
setIsInteracting(true);
|
|
195
|
+
}
|
|
196
|
+
function pointerMoveHandler(event) {
|
|
197
|
+
if (element === null) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const index = zoomEventCacheRef.current.findIndex(cachedEv => cachedEv.pointerId === event.pointerId);
|
|
201
|
+
zoomEventCacheRef.current[index] = event;
|
|
202
|
+
|
|
203
|
+
// Not a pinch gesture
|
|
204
|
+
if (zoomEventCacheRef.current.length !== 2) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const firstEvent = zoomEventCacheRef.current[0];
|
|
208
|
+
const curDiff = getDiff(zoomEventCacheRef.current);
|
|
209
|
+
setZoomDataCallback(prevZoomData => {
|
|
210
|
+
const newZoomData = prevZoomData.map(zoom => {
|
|
211
|
+
const option = optionsLookup[zoom.axisId];
|
|
212
|
+
if (!option) {
|
|
213
|
+
return zoom;
|
|
214
|
+
}
|
|
215
|
+
const {
|
|
216
|
+
scaleRatio,
|
|
217
|
+
isZoomIn
|
|
218
|
+
} = getPinchScaleRatio(curDiff, eventPrevDiff.current, option.step);
|
|
219
|
+
|
|
220
|
+
// If the scale ratio is 0, it means the pinch gesture is not valid.
|
|
221
|
+
if (scaleRatio === 0) {
|
|
222
|
+
return zoom;
|
|
223
|
+
}
|
|
224
|
+
const point = getSVGPoint(element, firstEvent);
|
|
225
|
+
const centerRatio = option.axisDirection === 'x' ? getHorizontalCenterRatio(point, drawingArea) : getVerticalCenterRatio(point, drawingArea);
|
|
226
|
+
const [newMinRange, newMaxRange] = zoomAtPoint(centerRatio, scaleRatio, zoom, option);
|
|
227
|
+
if (!isSpanValid(newMinRange, newMaxRange, isZoomIn, option)) {
|
|
228
|
+
return zoom;
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
axisId: zoom.axisId,
|
|
232
|
+
start: newMinRange,
|
|
233
|
+
end: newMaxRange
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
eventPrevDiff.current = curDiff;
|
|
237
|
+
return newZoomData;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function pointerUpHandler(event) {
|
|
241
|
+
zoomEventCacheRef.current.splice(zoomEventCacheRef.current.findIndex(cachedEvent => cachedEvent.pointerId === event.pointerId), 1);
|
|
242
|
+
if (zoomEventCacheRef.current.length < 2) {
|
|
243
|
+
eventPrevDiff.current = 0;
|
|
244
|
+
}
|
|
245
|
+
if (event.type === 'pointerup' || event.type === 'pointercancel') {
|
|
246
|
+
setIsInteracting(false);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
element.addEventListener('wheel', wheelHandler);
|
|
250
|
+
element.addEventListener('pointerdown', pointerDownHandler);
|
|
251
|
+
element.addEventListener('pointermove', pointerMoveHandler);
|
|
252
|
+
element.addEventListener('pointerup', pointerUpHandler);
|
|
253
|
+
element.addEventListener('pointercancel', pointerUpHandler);
|
|
254
|
+
element.addEventListener('pointerout', pointerUpHandler);
|
|
255
|
+
element.addEventListener('pointerleave', pointerUpHandler);
|
|
256
|
+
|
|
257
|
+
// Prevent zooming the entire page on touch devices
|
|
258
|
+
element.addEventListener('touchstart', preventDefault);
|
|
259
|
+
element.addEventListener('touchmove', preventDefault);
|
|
260
|
+
return () => {
|
|
261
|
+
element.removeEventListener('wheel', wheelHandler);
|
|
262
|
+
element.removeEventListener('pointerdown', pointerDownHandler);
|
|
263
|
+
element.removeEventListener('pointermove', pointerMoveHandler);
|
|
264
|
+
element.removeEventListener('pointerup', pointerUpHandler);
|
|
265
|
+
element.removeEventListener('pointercancel', pointerUpHandler);
|
|
266
|
+
element.removeEventListener('pointerout', pointerUpHandler);
|
|
267
|
+
element.removeEventListener('pointerleave', pointerUpHandler);
|
|
268
|
+
element.removeEventListener('touchstart', preventDefault);
|
|
269
|
+
element.removeEventListener('touchmove', preventDefault);
|
|
270
|
+
if (interactionTimeoutRef.current) {
|
|
271
|
+
clearTimeout(interactionTimeoutRef.current);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}, [svgRef, drawingArea, isZoomEnabled, optionsLookup, setIsInteracting, instance, setZoomDataCallback]);
|
|
275
|
+
return {
|
|
276
|
+
publicAPI: {
|
|
277
|
+
setZoomData: setZoomDataCallback
|
|
278
|
+
},
|
|
279
|
+
instance: {
|
|
280
|
+
setZoomData: setZoomDataCallback
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
useChartProZoom.params = {
|
|
285
|
+
initialZoom: true,
|
|
286
|
+
onZoomChange: true
|
|
287
|
+
};
|
|
288
|
+
useChartProZoom.getDefaultizedParams = ({
|
|
289
|
+
params
|
|
290
|
+
}) => {
|
|
291
|
+
const optionsLookup = _extends({}, params.defaultizedXAxis.reduce((acc, v) => {
|
|
292
|
+
const {
|
|
293
|
+
zoom,
|
|
294
|
+
id: axisId
|
|
295
|
+
} = v;
|
|
296
|
+
const defaultizedZoom = defaultizeZoom(zoom, axisId, 'x');
|
|
297
|
+
if (defaultizedZoom) {
|
|
298
|
+
acc[axisId] = defaultizedZoom;
|
|
299
|
+
}
|
|
300
|
+
return acc;
|
|
301
|
+
}, {}), params.defaultizedYAxis.reduce((acc, v) => {
|
|
302
|
+
const {
|
|
303
|
+
zoom,
|
|
304
|
+
id: axisId
|
|
305
|
+
} = v;
|
|
306
|
+
const defaultizedZoom = defaultizeZoom(zoom, axisId, 'y');
|
|
307
|
+
if (defaultizedZoom) {
|
|
308
|
+
acc[axisId] = defaultizedZoom;
|
|
309
|
+
}
|
|
310
|
+
return acc;
|
|
311
|
+
}, {}));
|
|
312
|
+
return _extends({}, params, {
|
|
313
|
+
optionsLookup
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
useChartProZoom.getInitialState = params => {
|
|
317
|
+
return {
|
|
318
|
+
zoom: {
|
|
319
|
+
optionsLookup: params.optionsLookup,
|
|
320
|
+
zoomData: params.initialZoom === undefined ? initializeZoomData(params.optionsLookup) : params.initialZoom,
|
|
321
|
+
isInteracting: false
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ChartRootSelector } from '@mui/x-charts/internals';
|
|
2
|
+
import { UseChartProZoomSignature } from './useChartProZoom.types';
|
|
3
|
+
export declare const selectorChartZoomState: ChartRootSelector<UseChartProZoomSignature>;
|
|
4
|
+
export declare const selectorChartZoomOptionsLookup: ((state: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("./useChartProZoom.types").UseChartProZoomState & Partial<{}> & {
|
|
5
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
6
|
+
}) => Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>) & {
|
|
7
|
+
clearCache: () => void;
|
|
8
|
+
resultsCount: () => number;
|
|
9
|
+
resetResultsCount: () => void;
|
|
10
|
+
} & {
|
|
11
|
+
resultFunc: (resultFuncArgs_0: {
|
|
12
|
+
optionsLookup: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
13
|
+
isInteracting: boolean;
|
|
14
|
+
zoomData: import("@mui/x-charts/internals").ZoomData[];
|
|
15
|
+
}) => Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
16
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
17
|
+
optionsLookup: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
18
|
+
isInteracting: boolean;
|
|
19
|
+
zoomData: import("@mui/x-charts/internals").ZoomData[];
|
|
20
|
+
}) => Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>) & {
|
|
21
|
+
clearCache: () => void;
|
|
22
|
+
resultsCount: () => number;
|
|
23
|
+
resetResultsCount: () => void;
|
|
24
|
+
};
|
|
25
|
+
lastResult: () => Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
26
|
+
dependencies: [ChartRootSelector<UseChartProZoomSignature>];
|
|
27
|
+
recomputations: () => number;
|
|
28
|
+
resetRecomputations: () => void;
|
|
29
|
+
dependencyRecomputations: () => number;
|
|
30
|
+
resetDependencyRecomputations: () => void;
|
|
31
|
+
} & {
|
|
32
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
33
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
34
|
+
};
|
|
35
|
+
export declare const selectorChartZoomData: ((state: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("./useChartProZoom.types").UseChartProZoomState & Partial<{}> & {
|
|
36
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
37
|
+
}) => import("@mui/x-charts/internals").ZoomData[]) & {
|
|
38
|
+
clearCache: () => void;
|
|
39
|
+
resultsCount: () => number;
|
|
40
|
+
resetResultsCount: () => void;
|
|
41
|
+
} & {
|
|
42
|
+
resultFunc: (resultFuncArgs_0: {
|
|
43
|
+
optionsLookup: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
44
|
+
isInteracting: boolean;
|
|
45
|
+
zoomData: import("@mui/x-charts/internals").ZoomData[];
|
|
46
|
+
}) => import("@mui/x-charts/internals").ZoomData[];
|
|
47
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
48
|
+
optionsLookup: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
49
|
+
isInteracting: boolean;
|
|
50
|
+
zoomData: import("@mui/x-charts/internals").ZoomData[];
|
|
51
|
+
}) => import("@mui/x-charts/internals").ZoomData[]) & {
|
|
52
|
+
clearCache: () => void;
|
|
53
|
+
resultsCount: () => number;
|
|
54
|
+
resetResultsCount: () => void;
|
|
55
|
+
};
|
|
56
|
+
lastResult: () => import("@mui/x-charts/internals").ZoomData[];
|
|
57
|
+
dependencies: [ChartRootSelector<UseChartProZoomSignature>];
|
|
58
|
+
recomputations: () => number;
|
|
59
|
+
resetRecomputations: () => void;
|
|
60
|
+
dependencyRecomputations: () => number;
|
|
61
|
+
resetDependencyRecomputations: () => void;
|
|
62
|
+
} & {
|
|
63
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
64
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
65
|
+
};
|
|
66
|
+
export declare const selectorChartZoomIsInteracting: ((state: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("./useChartProZoom.types").UseChartProZoomState & Partial<{}> & {
|
|
67
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
68
|
+
}) => boolean) & {
|
|
69
|
+
clearCache: () => void;
|
|
70
|
+
resultsCount: () => number;
|
|
71
|
+
resetResultsCount: () => void;
|
|
72
|
+
} & {
|
|
73
|
+
resultFunc: (resultFuncArgs_0: {
|
|
74
|
+
optionsLookup: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
75
|
+
isInteracting: boolean;
|
|
76
|
+
zoomData: import("@mui/x-charts/internals").ZoomData[];
|
|
77
|
+
}) => boolean;
|
|
78
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
79
|
+
optionsLookup: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
80
|
+
isInteracting: boolean;
|
|
81
|
+
zoomData: import("@mui/x-charts/internals").ZoomData[];
|
|
82
|
+
}) => boolean) & {
|
|
83
|
+
clearCache: () => void;
|
|
84
|
+
resultsCount: () => number;
|
|
85
|
+
resetResultsCount: () => void;
|
|
86
|
+
};
|
|
87
|
+
lastResult: () => boolean;
|
|
88
|
+
dependencies: [ChartRootSelector<UseChartProZoomSignature>];
|
|
89
|
+
recomputations: () => number;
|
|
90
|
+
resetRecomputations: () => void;
|
|
91
|
+
dependencyRecomputations: () => number;
|
|
92
|
+
resetDependencyRecomputations: () => void;
|
|
93
|
+
} & {
|
|
94
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
95
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
96
|
+
};
|
|
97
|
+
export declare const selectorChartZoomIsEnabled: ((state: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("./useChartProZoom.types").UseChartProZoomState & Partial<{}> & {
|
|
98
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
99
|
+
}) => boolean) & {
|
|
100
|
+
clearCache: () => void;
|
|
101
|
+
resultsCount: () => number;
|
|
102
|
+
resetResultsCount: () => void;
|
|
103
|
+
} & {
|
|
104
|
+
resultFunc: (resultFuncArgs_0: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>) => boolean;
|
|
105
|
+
memoizedResultFunc: ((resultFuncArgs_0: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>) => boolean) & {
|
|
106
|
+
clearCache: () => void;
|
|
107
|
+
resultsCount: () => number;
|
|
108
|
+
resetResultsCount: () => void;
|
|
109
|
+
};
|
|
110
|
+
lastResult: () => boolean;
|
|
111
|
+
dependencies: [((state: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("./useChartProZoom.types").UseChartProZoomState & Partial<{}> & {
|
|
112
|
+
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
113
|
+
}) => Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>) & {
|
|
114
|
+
clearCache: () => void;
|
|
115
|
+
resultsCount: () => number;
|
|
116
|
+
resetResultsCount: () => void;
|
|
117
|
+
} & {
|
|
118
|
+
resultFunc: (resultFuncArgs_0: {
|
|
119
|
+
optionsLookup: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
120
|
+
isInteracting: boolean;
|
|
121
|
+
zoomData: import("@mui/x-charts/internals").ZoomData[];
|
|
122
|
+
}) => Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
123
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
124
|
+
optionsLookup: Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
125
|
+
isInteracting: boolean;
|
|
126
|
+
zoomData: import("@mui/x-charts/internals").ZoomData[];
|
|
127
|
+
}) => Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>) & {
|
|
128
|
+
clearCache: () => void;
|
|
129
|
+
resultsCount: () => number;
|
|
130
|
+
resetResultsCount: () => void;
|
|
131
|
+
};
|
|
132
|
+
lastResult: () => Record<import("@mui/x-charts/internals").AxisId, import("@mui/x-charts/internals").DefaultizedZoomOptions>;
|
|
133
|
+
dependencies: [ChartRootSelector<UseChartProZoomSignature>];
|
|
134
|
+
recomputations: () => number;
|
|
135
|
+
resetRecomputations: () => void;
|
|
136
|
+
dependencyRecomputations: () => number;
|
|
137
|
+
resetDependencyRecomputations: () => void;
|
|
138
|
+
} & {
|
|
139
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
140
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
141
|
+
}];
|
|
142
|
+
recomputations: () => number;
|
|
143
|
+
resetRecomputations: () => void;
|
|
144
|
+
dependencyRecomputations: () => number;
|
|
145
|
+
resetDependencyRecomputations: () => void;
|
|
146
|
+
} & {
|
|
147
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
148
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
149
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createSelector } from '@mui/x-charts/internals';
|
|
2
|
+
export const selectorChartZoomState = state => state.zoom;
|
|
3
|
+
export const selectorChartZoomOptionsLookup = createSelector(selectorChartZoomState, zoom => zoom.optionsLookup);
|
|
4
|
+
export const selectorChartZoomData = createSelector(selectorChartZoomState, zoom => zoom.zoomData);
|
|
5
|
+
export const selectorChartZoomIsInteracting = createSelector(selectorChartZoomState, zoom => zoom.isInteracting);
|
|
6
|
+
export const selectorChartZoomIsEnabled = createSelector(selectorChartZoomOptionsLookup, optionsLookup => Object.keys(optionsLookup).length > 0);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AxisId, UseChartSeriesSignature, ChartPluginSignature, DefaultizedZoomOptions, UseChartCartesianAxisSignature, UseChartCartesianAxisDefaultizedParameters, ZoomData } from '@mui/x-charts/internals';
|
|
2
|
+
export interface UseChartProZoomParameters {
|
|
3
|
+
/**
|
|
4
|
+
* The list of zoom data related to each axis.
|
|
5
|
+
*/
|
|
6
|
+
initialZoom?: ZoomData[];
|
|
7
|
+
/**
|
|
8
|
+
* Callback fired when the zoom has changed.
|
|
9
|
+
*
|
|
10
|
+
* @param {ZoomData[]} zoomData Updated zoom data.
|
|
11
|
+
*/
|
|
12
|
+
onZoomChange?: (zoomData: ZoomData[] | ((zoomData: ZoomData[]) => ZoomData[])) => void;
|
|
13
|
+
}
|
|
14
|
+
export type UseChartProZoomDefaultizedParameters = UseChartProZoomParameters & UseChartCartesianAxisDefaultizedParameters & {
|
|
15
|
+
/**
|
|
16
|
+
* The zoom options for each axis.
|
|
17
|
+
*/
|
|
18
|
+
optionsLookup: Record<AxisId, DefaultizedZoomOptions>;
|
|
19
|
+
};
|
|
20
|
+
export interface UseChartProZoomState {
|
|
21
|
+
zoom: {
|
|
22
|
+
/**
|
|
23
|
+
* The zoom options for each axis.
|
|
24
|
+
*/
|
|
25
|
+
optionsLookup: Record<AxisId, DefaultizedZoomOptions>;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the user is currently interacting with the chart.
|
|
28
|
+
* This is useful to disable animations while the user is interacting.
|
|
29
|
+
*/
|
|
30
|
+
isInteracting: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Mapping of axis id to the zoom data.
|
|
33
|
+
*/
|
|
34
|
+
zoomData: ZoomData[];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface UseChartProZoomPublicApi {
|
|
38
|
+
/**
|
|
39
|
+
* Set the zoom data state.
|
|
40
|
+
* @param {ZoomData[] | ((prev: ZoomData[]) => ZoomData[])} value The new value. Can either be the new zoom data, or an updater function.
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*/
|
|
43
|
+
setZoomData: (value: ZoomData[] | ((prev: ZoomData[]) => ZoomData[])) => void;
|
|
44
|
+
}
|
|
45
|
+
export interface UseChartProZoomInstance extends UseChartProZoomPublicApi {
|
|
46
|
+
}
|
|
47
|
+
export type UseChartProZoomSignature = ChartPluginSignature<{
|
|
48
|
+
params: UseChartProZoomParameters;
|
|
49
|
+
defaultizedParams: UseChartProZoomDefaultizedParameters;
|
|
50
|
+
state: UseChartProZoomState;
|
|
51
|
+
publicAPI: UseChartProZoomPublicApi;
|
|
52
|
+
instance: UseChartProZoomInstance;
|
|
53
|
+
dependencies: [UseChartSeriesSignature, UseChartCartesianAxisSignature];
|
|
54
|
+
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DefaultizedZoomOptions, ZoomData } from '@mui/x-charts/internals';
|
|
2
|
+
/**
|
|
3
|
+
* Helper to get the range (in percents of a reference range) corresponding to a given scale.
|
|
4
|
+
* @param centerRatio {number} The ratio of the point that should not move between the previous and next range.
|
|
5
|
+
* @param scaleRatio {number} The target scale ratio.
|
|
6
|
+
* @returns The range to display.
|
|
7
|
+
*/
|
|
8
|
+
export declare const zoomAtPoint: (centerRatio: number, scaleRatio: number, currentZoomData: ZoomData, options: DefaultizedZoomOptions) => number[];
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the new span is valid.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isSpanValid(minRange: number, maxRange: number, isZoomIn: boolean, option: DefaultizedZoomOptions): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Get the scale ratio and if it's a zoom in or out from a wheel event.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getWheelScaleRatio(event: WheelEvent, step: number): {
|
|
17
|
+
scaleRatio: number;
|
|
18
|
+
isZoomIn: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get the scale ratio and if it's a zoom in or out from a pinch gesture.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getPinchScaleRatio(curDiff: number, prevDiff: number, step: number): {
|
|
24
|
+
scaleRatio: number;
|
|
25
|
+
isZoomIn: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare function getDiff(eventCache: PointerEvent[]): number;
|
|
28
|
+
/**
|
|
29
|
+
* Get the ratio of the point in the horizontal center of the area.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getHorizontalCenterRatio(point: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
}, area: {
|
|
35
|
+
left: number;
|
|
36
|
+
width: number;
|
|
37
|
+
}): number;
|
|
38
|
+
export declare function preventDefault(event: TouchEvent): void;
|
|
39
|
+
export declare function getVerticalCenterRatio(point: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
}, area: {
|
|
43
|
+
top: number;
|
|
44
|
+
height: number;
|
|
45
|
+
}): number;
|