@osrd-project/ui-charts 0.0.73 → 0.0.74

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/dist/index.esm.js CHANGED
@@ -603,8 +603,8 @@ function useCanvas$1(dom, inputStcContext, position) {
603
603
  const ratio = isPicking ? pickingScalingRatio : devicePixelRatio;
604
604
  canvas.style.width = size.width + 'px';
605
605
  canvas.style.height = size.height + 'px';
606
- canvas.setAttribute('width', size.width * ratio + 'px');
607
- canvas.setAttribute('height', size.height * ratio + 'px');
606
+ canvas.setAttribute('width', Math.max(1, size.width * ratio) + 'px');
607
+ canvas.setAttribute('height', Math.max(1, size.height * ratio) + 'px');
608
608
  if (!isPicking) {
609
609
  // Reset the transform to identity, then apply the new scale
610
610
  ctx.setTransform(1, 0, 0, 1, 0, 0);
@@ -2571,14 +2571,18 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
2571
2571
  const resetZoom = useCallback(() => {
2572
2572
  setState((prev) => ({ ...prev, yZoom: 1 }));
2573
2573
  }, []);
2574
- const handleScroll = useCallback(() => {
2574
+ const handleScroll = useCallback((e) => {
2575
+ if (rect) {
2576
+ e.preventDefault();
2577
+ return;
2578
+ }
2575
2579
  if (!isShiftPressed && manchetteWithSpaceTimeChartRef.current) {
2576
2580
  const { scrollTop } = manchetteWithSpaceTimeChartRef.current;
2577
2581
  if (scrollTop || scrollTop === 0) {
2578
2582
  setState((prev) => ({ ...prev, yOffset: scrollTop }));
2579
2583
  }
2580
2584
  }
2581
- }, [isShiftPressed, manchetteWithSpaceTimeChartRef]);
2585
+ }, [isShiftPressed, manchetteWithSpaceTimeChartRef, rect]);
2582
2586
  const handleKeyDown = useCallback((event) => {
2583
2587
  if (event.key === 'Shift') {
2584
2588
  setIsShiftPressed(true);
@@ -2770,7 +2774,7 @@ const useManchetteWithSpaceTimeChart = ({ waypoints, manchetteWithSpaceTimeChart
2770
2774
  spaceOrigin,
2771
2775
  spaceScales,
2772
2776
  onZoom: ({ delta, position, }) => {
2773
- if (isShiftPressed) {
2777
+ if (isShiftPressed && !rect) {
2774
2778
  handleXZoom(xZoom + delta, position.x);
2775
2779
  }
2776
2780
  },