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

jcrop.newCropper is not a function #304

Open
nunoperalta opened this issue Aug 30, 2021 · 2 comments
Open

jcrop.newCropper is not a function #304

nunoperalta opened this issue Aug 30, 2021 · 2 comments

Comments

@nunoperalta
Copy link

nunoperalta commented Aug 30, 2021

In these examples:

https://jcrop.com/guide/widgets.html#creating-a-widget
https://jcrop.com/guide/instance.html#newwidget-rect-options

const jcrop = Jcrop.attach('target');
const rect = Jcrop.Rect.fromPoints([100,100],[200,200]);
jcrop.newCropper(rect,{ aspectRatio: rect.aspect });

TypeError: jcrop.newCropper is not a function

I'm finding it really hard to get this working, and unfortunately the documentation is very confusing or incomplete.
(eventually got this figured out)

Would be nice if the page at: https://jcrop.com/examples/
could have an example source code that I could copy from, as it seems to do exactly what I want.

I'm simply looking to put a default cropper active, centered to the image, with fixed aspect ratio.

@manchumahara
Copy link

@nunoperalta you wrote (eventually got this figured out). Can you share how you fixed ? I am also looking in docs but can not find solution exactly. More code based working example could help.

@nunoperalta
Copy link
Author

nunoperalta commented Jul 25, 2022

Hey

I can't remember exactly, but here's what I have currently:

		Jcrop.load('img-to-crop').then(function (img) {
			var jcrop = Jcrop.attach(img);
			var rect = Jcrop.Rect.create(x, y, w, h);
			jcrop.newWidget(rect, { aspectRatio: rect.aspect });
			...
			jcrop.destroy();
		});

The position can be accessed through jcrop.active.pos

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