fengyuanchen / cropper

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

How to manually set the height and width of the cropbox? #1082

Closed HeyLetsDebug closed 4 years ago

HeyLetsDebug commented 4 years ago

Hi @fengyuanchen

I am trying to set the cropbox height and width via user input and have achieved upto some extent but not sure why the size again changes back to normal on dragging the cropbox.

1. As shown below once I select the options (height and width) and hit start crop the cropbox area gets resized.

///////CODE USED FOR THIS/////////

document.getElementById("start-crop").addEventListener('click', function(){ var cropperCropBox = document.getElementsByClassName("cropper-crop-box") cropperCropBox[0].style.width= document.getElementById("width").value + "px"; cropperCropBox[0].style.height= document.getElementById("height").value + "px"; });

at-setting-data

2. But as soon as I start dragging the cropBox the size again changes to original :(

after-drag-data-changes

Please help!! Also I am using plain javascript to do so and not jQuery..

HeyLetsDebug commented 4 years ago

resolved