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

Cropzone Issues? #15

Closed
SmboBeast opened this issue Dec 20, 2016 · 3 comments
Closed

Cropzone Issues? #15

SmboBeast opened this issue Dec 20, 2016 · 3 comments

Comments

@SmboBeast
Copy link

Hi,

I'm trying to incorporate just the Cropzone pieces into my own React app, but am having difficulties. For some reason, when _getCoordinates is hit, canvasEl.getWidth() and canvasEl.getHeight() come back as 1. This essentially draws a small dot it's everything is only 1 square pixel in size.

Have you had any issues like this? When debugging through the core of fabricjs and going through the call stack, looking at this line (12553): this.drawObject(this._cacheContext, noTransform); - I see this._cacheContext being very different than the ctx in the call stack line before (line 6862): objects[i] && objects[i].render(ctx);

In the render line above (6862), the ctx seems to be correct and is pointing to the canvas we need it to point to. However, by the time line 12553 is hit, the _cacheContext is different.

Wondering if you've seen this type of issue?

@SmboBeast
Copy link
Author

Looks like I have an update here. For some reason, cropzone is only actually added successfully if I pass an objectCaching: false property when creating the cropZone. Still haven't figured out why though...

@minkyu-yi
Copy link

minkyu-yi commented Dec 22, 2016

image

when _getCoordinates is hit, canvasEl.getWidth() and canvasEl.getHeight() come back as 1.

The this.getWidth() is a fabric-Rect api. And the canvasEl.width is an attribute of canvas element.

What is the canvasEl.getWidth() in your context? (Sorry, Im not goot at english 😅)

@SmboBeast
Copy link
Author

SmboBeast commented Dec 27, 2016

No, your English is just fine. :)

Sorry for the delay, it's been the holidays here. So, my fabric canvas is set to 500x500.

If I have objectCaching: false, when creating a new cropzone rect, the context seems to have the right canvas and getWidth and getHeight come back as 500, which is right.

When I don't include objectCaching, getWidth and getHeight come back as exactly the same values as width and height (which is what the cropzone actually is). What's actually weird is canvasEl is pointing to a canvas element that doesn't even exist when I dig through it. So it's obvious it's referencing a different canvas.

In your case, ctx references the lower canvas, so things work just fine. In my case, although the lower canvas exists, ctx actually refers to a brand new canvas. This canvas doesn't even exist in the DOM.

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

No branches or pull requests

2 participants