nhn / tui.image-editor

🍞🎨 Full-featured photo image editor using canvas. It is really easy, and it comes with great filters.
http://ui.toast.com/tui-image-editor
MIT License
6.83k stars 1.26k forks source link

How to start custom crop option? #901

Open TmVukov opened 5 months ago

TmVukov commented 5 months ago

Obviously, that option exists, but when i try to replicate it, i'm getting errors.

So i'm literally trying to implement this code from your "service-basic.js" file, which, as far as I can see, starts the custom crop mode:

$btnCrop.on('click', function () {
  imageEditor.startDrawingMode('CROPPER');
  $displayingSubMenu.hide();
  $displayingSubMenu = $cropSubMenu.show();
});

The example code in React would be something like this:

const handleCustomCrop = () => {
        if (editorRef.current) {
            const imageEditor = editorRef.current.getInstance()
            imageEditor.startDrawingMode('CROPPER')
        }
    }

This shows the plus icon to start cropping, but when I try to do that i get this error?

Cannot read properties of null (reading 'set') TypeError: Cannot read properties of null (reading 'set') at Cropper._onFabricMouseMove (http://localhost:3000/static/js/bundle.js:518311:24) at klass.fire (http://localhost:3000/static/js/bundle.js:472426:60) at klass._handleEvent (http://localhost:3000/static/js/bundle.js:484075:20) at klass.__onMouseMove (http://localhost:3000/static/js/bundle.js:484338:20) at klass._onMouseMove (http://localhost:3000/static/js/bundle.js:483922:20)

nulifendou11 commented 2 months ago

遇到了同样的问题