@parca/profile 0.16.62 → 0.16.63

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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.16.63](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.62...@parca/profile@0.16.63) (2022-11-08)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
6
10
  ## 0.16.62 (2022-11-08)
7
11
 
8
12
  **Note:** Version bump only for package @parca/profile
@@ -108,7 +108,7 @@ var Callgraph = function (_a) {
108
108
  }), stage = _f[0], setStage = _f[1];
109
109
  var rawNodes = graph.nodes, total = graph.cumulative;
110
110
  var currentSearchString = useAppSelector(selectSearchNodeString);
111
- var isSearchEmpty = currentSearchString === undefined;
111
+ var isSearchEmpty = currentSearchString === undefined || currentSearchString === '';
112
112
  useEffect(function () {
113
113
  var getDataWithPositions = function () { return __awaiter(void 0, void 0, void 0, function () {
114
114
  var dataAsDot, jsonGraph;
@@ -159,24 +159,29 @@ var Callgraph = function (_a) {
159
159
  // 4. Add zooming
160
160
  var handleWheel = function (e) {
161
161
  var _a;
162
+ // stop default scrolling
162
163
  e.evt.preventDefault();
163
- var scaleXBy = 0.95;
164
- var scaleYBy = 1.05;
164
+ var scaleBy = 1.01;
165
165
  var stage = e.target.getStage();
166
166
  if (stage !== null) {
167
167
  var oldScale = stage.scaleX();
168
- var _b = (_a = stage.getPointerPosition()) !== null && _a !== void 0 ? _a : { x: 0, y: 0 }, x = _b.x, y = _b.y;
168
+ var pointer = (_a = stage.getPointerPosition()) !== null && _a !== void 0 ? _a : { x: 0, y: 0 };
169
169
  var mousePointTo = {
170
- x: x / oldScale - stage.x() / oldScale,
171
- y: y / oldScale - stage.y() / oldScale,
170
+ x: pointer.x / oldScale - stage.x() / oldScale,
171
+ y: pointer.y / oldScale - stage.y() / oldScale,
172
172
  };
173
- var newXScale = e.evt.deltaX > 0 ? oldScale * scaleXBy : oldScale / scaleXBy;
174
- var newYScale = e.evt.deltaY > 0 ? oldScale * scaleYBy : oldScale / scaleYBy;
175
- stage.scale({ x: newXScale, y: newYScale });
173
+ // whether to zoom in or out
174
+ var direction = e.evt.deltaY > 0 ? 1 : -1;
175
+ // for trackpad, e.evt.ctrlKey is true => in that case, revert direction
176
+ if (e.evt.ctrlKey) {
177
+ direction = -direction;
178
+ }
179
+ var newScale = direction > 0 ? oldScale * scaleBy : oldScale / scaleBy;
180
+ stage.scale({ x: newScale, y: newScale });
176
181
  setStage({
177
- scale: { x: newXScale, y: newYScale },
178
- x: -(mousePointTo.x - x / newXScale) * newXScale,
179
- y: -(mousePointTo.y - y / newYScale) * newYScale,
182
+ scale: { x: newScale, y: newScale },
183
+ x: -(mousePointTo.x - pointer.x / newScale) * newScale,
184
+ y: -(mousePointTo.y - pointer.y / newScale) * newScale,
180
185
  });
181
186
  }
182
187
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.62",
3
+ "version": "0.16.63",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@iconify/react": "^3.2.2",
@@ -40,5 +40,5 @@
40
40
  "access": "public",
41
41
  "registry": "https://registry.npmjs.org/"
42
42
  },
43
- "gitHead": "34f834e5c01e7dce7aa7cb1b09fe861d413ac0a3"
43
+ "gitHead": "a244d1d0c99589df268a4d93a56c9c67cce6236f"
44
44
  }
@@ -180,7 +180,7 @@ const Callgraph = ({graph, sampleUnit, width, colorRange}: Props): JSX.Element =
180
180
  });
181
181
  const {nodes: rawNodes, cumulative: total} = graph;
182
182
  const currentSearchString = useAppSelector(selectSearchNodeString);
183
- const isSearchEmpty = currentSearchString === undefined;
183
+ const isSearchEmpty = currentSearchString === undefined || currentSearchString === '';
184
184
 
185
185
  useEffect(() => {
186
186
  const getDataWithPositions = async (): Promise<void> => {
@@ -233,29 +233,35 @@ const Callgraph = ({graph, sampleUnit, width, colorRange}: Props): JSX.Element =
233
233
 
234
234
  // 4. Add zooming
235
235
  const handleWheel: (e: KonvaEventObject<WheelEvent>) => void = e => {
236
+ // stop default scrolling
236
237
  e.evt.preventDefault();
237
238
 
238
- const scaleXBy = 0.95;
239
- const scaleYBy = 1.05;
239
+ const scaleBy = 1.01;
240
240
  const stage = e.target.getStage();
241
241
 
242
242
  if (stage !== null) {
243
243
  const oldScale = stage.scaleX();
244
- const {x, y} = stage.getPointerPosition() ?? {x: 0, y: 0};
244
+ const pointer = stage.getPointerPosition() ?? {x: 0, y: 0};
245
245
  const mousePointTo = {
246
- x: x / oldScale - stage.x() / oldScale,
247
- y: y / oldScale - stage.y() / oldScale,
246
+ x: pointer.x / oldScale - stage.x() / oldScale,
247
+ y: pointer.y / oldScale - stage.y() / oldScale,
248
248
  };
249
249
 
250
- const newXScale = e.evt.deltaX > 0 ? oldScale * scaleXBy : oldScale / scaleXBy;
251
- const newYScale = e.evt.deltaY > 0 ? oldScale * scaleYBy : oldScale / scaleYBy;
250
+ // whether to zoom in or out
251
+ let direction = e.evt.deltaY > 0 ? 1 : -1;
252
252
 
253
- stage.scale({x: newXScale, y: newYScale});
253
+ // for trackpad, e.evt.ctrlKey is true => in that case, revert direction
254
+ if (e.evt.ctrlKey) {
255
+ direction = -direction;
256
+ }
257
+
258
+ const newScale = direction > 0 ? oldScale * scaleBy : oldScale / scaleBy;
259
+ stage.scale({x: newScale, y: newScale});
254
260
 
255
261
  setStage({
256
- scale: {x: newXScale, y: newYScale},
257
- x: -(mousePointTo.x - x / newXScale) * newXScale,
258
- y: -(mousePointTo.y - y / newYScale) * newYScale,
262
+ scale: {x: newScale, y: newScale},
263
+ x: -(mousePointTo.x - pointer.x / newScale) * newScale,
264
+ y: -(mousePointTo.y - pointer.y / newScale) * newScale,
259
265
  });
260
266
  }
261
267
  };