Cropper: manually set width and height on input tag

Created on 14 Jul 2019  路  8Comments  路  Source: fengyuanchen/cropper

Screenshot_1

How to do that when entering the size of the height or width, set selection manually in the box
or by pressed enter something like this

All 8 comments

@richdenis86 Hello. Today I did the same task, I used the method "setData"

@richdenis86 Hello. Today I did the same task, I used the method "setData"

I tried but I did not succeed, can you please explain how you did it? or show code snippet?

<input type="text" class="form-control" onchange="setData()" data-method="setData" id="dataHeight" placeholder="height">
something, like this doesnt work :(

@richdenis86

const setFieldValue = (name, event) => {
    const value = parseFloat(event.target.value);
    if (cropper() && !isNaN(value)) {
      cropper().setData({
        ...cropper().getData(),
        ...{ [name]: value }
      });
    }
  };

and view
<Input value={cropData.width} type="number" onChange={value => setFieldValue("width", value)} />

may be i don't understand or something wrong? it doesnt work, can you send me html files pls? its very important, [email protected]
Screenshot_1

@richdenis86 You can see cropper with input

big thank you bro, but when i 'm transfer this code to the html page , getiing error Uncaught TypeError: $image.cropper is not a function,
https://codepen.io/richdenis86/pen/LwZEOZ
i installed it without npm

Screenshot_2

solved,and finally its worked! thank you @oskvortsov !!! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ypcyc picture ypcyc  路  9Comments

ThameDBA picture ThameDBA  路  4Comments

hpolonkoev picture hpolonkoev  路  5Comments

SimonBriche picture SimonBriche  路  7Comments

sohaibameen picture sohaibameen  路  4Comments