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]: zoomToPoint ts is error #10224

Closed
7 tasks done
vaynevayne opened this issue Oct 17, 2024 · 9 comments
Closed
7 tasks done

[Bug]: zoomToPoint ts is error #10224

vaynevayne opened this issue Oct 17, 2024 · 9 comments
Assignees
Labels

Comments

@vaynevayne
Copy link

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have read and followed the Issue Tracker Guide
  • I have searched and referenced existing issues and discussions
  • I am filing a BUG report.
  • I have managed to reproduce the bug after upgrading to the latest version
  • I have created an accurate and minimal reproduction

Version

6.0.2

In What environments are you experiencing the problem?

No response

Node Version (if applicable)

None

Link To Reproduction

https://stackblitz.com/edit/vitejs-vite-eyhjps?file=src%2FFabric.tsx

Steps To Reproduce

image

image

Expected Behavior

Passing x y should be enough

Actual Behavior

error

Error Message & Stack Trace

No response

@vaynevayne
Copy link
Author

vaynevayne commented Oct 17, 2024

second ts error

canvasRef.current?.on('mouse:wheel', onMouseWheelHandler);
   const onMouseWheelHandler = (opt: TPointerEventInfo) => {
      console.log('onMouseWheelHandler', opt.e.deltaY);

    };

image

@asturur
Copy link
Member

asturur commented Oct 17, 2024

For the first point the function requires a point not an object with x and y. You have to use new Point(x, y).

For the second maybe we need to fix the types to clarify is a mousewheel event

@asturur asturur added the bug label Oct 17, 2024
@asturur asturur self-assigned this Oct 17, 2024
@zhe-he
Copy link
Contributor

zhe-he commented Oct 18, 2024

It seems there is no issue; this problem should be closed.

image

@asturur
Copy link
Member

asturur commented Oct 18, 2024

Yes looks like his own function has a strict type on TPointer event without the WheelEvent spec.
Thanks

@asturur asturur closed this as completed Oct 18, 2024
@vaynevayne
Copy link
Author

How should the type of each event be written? Is there a more uniform alias?

@asturur
Copy link
Member

asturur commented Oct 20, 2024

For the mousewheel event:
TPointerEventInfo<WheelEvent> should be the correct one.

@zhe-he
Copy link
Contributor

zhe-he commented Oct 21, 2024

How should the type of each event be written? Is there a more uniform alias?

When binding events, hover the mouse over 'e', and it will show you which types are available.

Here all the e's are defined:
https://github.com/fabricjs/fabric.js/blob/master/src/EventTypeDefs.ts

@vaynevayne
Copy link
Author

mosue:down mouse:up Not applicable mouseEvent,
I mean normalized, supporting the usage Ivent <'mouse:up'>, rather than trying it one by one

@asturur
Copy link
Member

asturur commented Oct 21, 2024

Is not that you have to try one by one, when you start writing your function you get the suggestion right there:

image

After you have your suggestion you can move your handler out of there and type it manually just copying from the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants