Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Echarts can't accurately(maybe naturally) handle MAC touchpad gestures. #17286

Open
jianqi-jin opened this issue Jun 28, 2022 · 2 comments
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature.

Comments

@jianqi-jin
Copy link

Version

5.3.3

Link to Minimal Reproduction

No response

Steps to Reproduce

1、Set dataZoom like this:

  {
    type: 'slider',
    show: true,
    xAxisIndex: [0],
    start: 1,
    end: 35
  },
  {
    type: 'slider',
    show: true,
    yAxisIndex: [0],
    left: '93%',
    start: 29,
    end: 36
  },
  {
    type: 'inside',
    xAxisIndex: [0],
    start: 1,
    end: 35
  },
  {
    type: 'inside',
    yAxisIndex: [0],
    start: 29,
    end: 36
  }

image

Current Behavior

When I use MAC touchpad to scale and move it, I just can't move it all direction. It just treat the gesture as scaling instead moving.

Expected Behavior

I want to move the chart through the gesture all direction(up、down、left and right). And when I separate my fingers, I want to scale it. Just like Chrome DevTools's timeline in performance panel.

image

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

@jianqi-jin jianqi-jin added the bug label Jun 28, 2022
@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Jun 28, 2022
@jianqi-jin
Copy link
Author

And I tried the optionzoomOnMouseWheel: 'ctrl', when I use touchpad. It works when scale but doesn't work when move.

@jianqi-jin
Copy link
Author

And I find relative code in file src/component/helper/RoamController.ts.

private _mousewheelHandler(e: ZRElementEvent) {
        const shouldZoom = isAvailableBehavior('zoomOnMouseWheel', e, this._opt);
        const shouldMove = isAvailableBehavior('moveOnMouseWheel', e, this._opt);
        const wheelDelta = e.wheelDelta;
        const absWheelDeltaDelta = Math.abs(wheelDelta);
        const originX = e.offsetX;
        const originY = e.offsetY;

        // wheelDelta maybe -0 in chrome mac.
        if (wheelDelta === 0 || (!shouldZoom && !shouldMove)) {
            return;
        }

        if (shouldZoom) {
            // Convenience:
            // Mac and VM Windows on Mac: scroll up: zoom out.
            // Windows: scroll up: zoom in.

            // FIXME: Should do more test in different environment.
            // wheelDelta is too complicated in difference nvironment
            // (https://developer.mozilla.org/en-US/docs/Web/Events/mousewheel),
            // although it has been normallized by zrender.
            // wheelDelta of mouse wheel is bigger than touch pad.
            const factor = absWheelDeltaDelta > 3 ? 1.4 : absWheelDeltaDelta > 1 ? 1.2 : 1.1;
            const scale = wheelDelta > 0 ? factor : 1 / factor;
            checkPointerAndTrigger(this, 'zoom', 'zoomOnMouseWheel', e, {
                scale: scale, originX: originX, originY: originY, isAvailableBehavior: null
            });
        }

        if (shouldMove) {
            // FIXME: Should do more test in different environment.
            const absDelta = Math.abs(wheelDelta);
            // wheelDelta of mouse wheel is bigger than touch pad.
            const scrollDelta = (wheelDelta > 0 ? 1 : -1) * (absDelta > 3 ? 0.4 : absDelta > 1 ? 0.15 : 0.05);
            checkPointerAndTrigger(this, 'scrollMove', 'moveOnMouseWheel', e, {
                scrollDelta: scrollDelta, originX: originX, originY: originY, isAvailableBehavior: null
            });
        }
    }

Can we set a callback when mouse wheel ? So then I can use a custom function to handle the moving and scaling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature.
Projects
None yet
1 participant