var ratio = width / height; //console.log(ratio); var $img = $("#target"); var w = $img.width(); var h = $img.height(); var xw = 0; var xh = 0; if (w > h) { xw = w; xh = h*ratio; } else { xh = h; xw = w*ratio; } jcrop_api.setOptions({ aspectRatio: ratio}); var dim = jcrop_api.getBounds(); var x = 0, y = 0, x_ = dim[0], y_ = dim[1]; var x_r = (x_ / ratio) - y_; var y_r = (y_ / ratio) - x_; var xr = w*ratio; var yr = h*ratio; if (x_r > 0) { x = x_r / 2; } if (y_r > 0) { y = y_r / 2; } jcrop_api.focus(); console.log("xw"+xw); console.log("xh="+xh); jcrop_api.aspectRatio(ratio); jcrop_api.setSelect(0, 0, xw, xh);
jak wybierzemy fototapetę, podamy 150 na 350 to dzieje się cyrk w którym nie powinno być klauna...