How to center JQuery JCrop in the center of the picture

牧云@^-^@ 提交于 2019-11-30 13:57:08

In case you are not able to figure out how to set the selection in the centre :

Check the setting options http://deepliquid.com/content/Jcrop_Manual.html#Setting_Options

Something like this (taken from the API ref) :

<script language="Javascript">

    jQuery(function($) {
        $('#target').Jcrop({
            onSelect:    showCoords,
            bgColor:     'black',
            bgOpacity:   .4,
            setSelect:   [ x, y, x1, y1 ],
            aspectRatio: 16 / 9
        });
    });

</script>

If w is the width and h is the height of the desired selection and W is the width of the image, H is the height of the image, the coordinates will be

x = W/2 - w/2
y = H/2 - h/2
x1 = x + w
y1 = y + h

(I hope my math is right :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!