fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper
MIT License
7.75k stars 1.74k forks source link

Zooming or Scaling with buttons not working #892

Closed chavab1 closed 7 years ago

chavab1 commented 7 years ago

I took over a site from a previous developer who has your tool installed. It's setup so user are not allowed to zoom in or scale images, however that needs to be added now. I set the correct options in the script and I'm able to zoom and scale using the mouse wheel. However, I've added buttons to allow the same functionality for users without mousewheels and that is where I come across my problem.

I looked over the code on the sample site and copied the same setup but I can't get mine to work correctly. Whenever, I click on either of the buttons the image on the modal zooms or scales, but it looks like the original image remains in the background. So after clicking on the button I'm left with multiple copies of the image stacked on top of each other. I also get a console error : TypeError: d is null

I've tried removing all of the options and just running this to initialize it:

$image = $('#logoImg img');
$image.cropper();

I then run

$image.cropper('zoom', -0.1) or $image.cropper('scale', 1)

I just want to be able to zoom out just like I'm able to do it using the mousewheel.

I'm using JQuery 1.12.2

Thanx

capture

fengyuanchen commented 7 years ago

Change the following code:

$image = $('#logoImg img');

To:

$image = $('#logoImg > img');
chavab1 commented 7 years ago

Thanx!!