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

Add custom crop functionality using ReactJS and TypeScript #923

Open
tripti-tgs opened this issue Jun 19, 2024 · 0 comments
Open

Add custom crop functionality using ReactJS and TypeScript #923

tripti-tgs opened this issue Jun 19, 2024 · 0 comments
Labels

Comments

@tripti-tgs
Copy link

tripti-tgs commented Jun 19, 2024

Hi,

I am having a problem. I want to add crop functionality using API of tui image editor

Summary :-

I tried to build crop function by api for this package but I am facing this problem and i don't know how is the problem
I have tried to implement it in react and type script so can you tell me where is the problem and what is missed

Code :-

const handleCrop = () => {
    const editorInstance = editorInstanceRef?.current;
    try {
      editorInstance.stopDrawingMode();
      editorInstance.startDrawingMode("CROPPER");
      editorInstance.setCropzoneRect(1, 1, 1, 1);
      setshowCropButton(true);
    } catch (err) {
      console.error(err);
    }
  };

  const handleCropApply = () => {
    const editorInstance = editorInstanceRef.current;
    editorInstance.crop(editorInstance.getCropzoneRect());
  };

Demo Link :-

https://codesandbox.io/p/sandbox/tui-crop-function-forked-vq3f7z?file=%2Fsrc%2FApp.tsx%3A53%2C1

Screenshots :-

image

image

Version :-

ReactJS: "18.2.0"
Typescript: "4.4.4"
tui-image-editor: "3.15.3"

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

1 participant