Nahid Nafi
Nahid Nafi

Reputation: 11

Fixed selection area and stop new selection in jcrop

i'm new in jQuery. and I'm trying to crop a picture using the jcrop plugin.
Here is my current code:

jQuery(document).ready(function () {
    var width = '<%=Session["imageWidth"]%>';
    var height = '<%=Session["imageHeight"]%>';

    jQuery('#imgCrop').Jcrop({
        boxWidth: 800, 
        boxHeight: 600,
        onSelect: storeCoords,
        bgColor: 'pink',
        bgOpacity: .6,
        setSelect: [0, 0, width, height],
        aspectRatio: 1
    });

});

function storeCoords(c) {
    jQuery('#X').val(c.x);
    jQuery('#Y').val(c.y);
    jQuery('#W').val(c.w);
    jQuery('#H').val(c.h);
};

Here everything is ok but the selection area is resizable.
What should I change in order to fix the selection area and stop the new selection?

Upvotes: 1

Views: 3527

Answers (1)

Hafeez
Hafeez

Reputation: 31

Use this code

    jQuery(document).ready(function() {
    jQuery('#imgCrop').Jcrop({
        aspectRatio: 1,
        setSelect:   [50, 0, 300,300],
        allowResize: false,
        allowSelect: false,
        onSelect: storeCoords
        });
    });

    function storeCoords(c) {
        jQuery('#X').val(c.x);
        jQuery('#Y').val(c.y);
        jQuery('#W').val(c.w);
        jQuery('#H').val(c.h);
    };

Upvotes: 3

Related Questions