Felix Felix - 1 month ago 7
Javascript Question

How to resize image with correct propotion in x and y axis using jquery resizable

Hi please see this https://jsfiddle.net/felixtm/x3xb2jwf/15/. Here i can change the size of the image . is it possible to resize the image proportionally with x and y axis ? currently i can enlarge the image to y axis without effecting the x axis . I want to change the image size that is proportional with both x and y axis.

i see this code in documentation

$( ".selector" ).resizable({
aspectRatio: true
});


i used
aspectRatio: true
,but nothing changing .

Answer

The aspectRatio of resizable() is exactly what you need. I can only presume you're not setting it on the correct element, try this:

$(".child2").resizable({
    aspectRatio: true
});

Updated fiddle