Jcrop setSelect错误的值

时间:2015-06-26 16:09:39

标签: jquery jcrop

我在我的应用程序中使用jcrop,我想打开带有选择(x, y, w, h)的图像,当我只提供x, width and height它可以工作时,但当我添加'y'的值时它没有给我正确的值

这是我的代码:

function initJcrop() {
                     $('#target').Jcrop({
                         aspectRatio: 3,  //If you want to keep aspectRatio
                          allowResize: true ,
                          boxWidth: 975,   //Maximum width you want for your bigger images
                          boxHeight: 325,  //Maximum Height for your bigger images
                          minSize: [900, 300],
                          <?php $image_crop =  json_decode($article->image_crop);?>
                          setSelect: [<?php echo $image_crop->x;?>, <?php echo $image_crop->y;?>, <?php echo $image_crop->w;?>, <?php echo $image_crop->h;?>],
                          allowSelect: false ,
                          onSelect: storeCoords ,
                          addClass: 'jcrop-centered',

                          onChange: storeCoords
                     },function()
                     {
    //                    alert('Now you see smaller preview of your bigger one.');
                     });
                    }



                function storeCoords(c) {
                    jQuery('#x').val(Math.round(c.x));
                    jQuery('#y').val(Math.round(c.y));
                    jQuery('#w').val(Math.round(c.w));
                    jQuery('#h').val(Math.round(c.h));

};

1 个答案:

答案 0 :(得分:0)

我知道问题被问到已经有一段时间了,但是在下面的帖子中可能有评论这对其他人(比如我)寻找答案很有帮助:https://github.com/tapmodo/Jcrop/issues/150