1

I'm trying to reproduce the example here http://jsfiddle.net/uydpr/2/ as the code is inside my page, but instead of getting the image area being selected, the image gets treated as click&drag. How can I prevent/stop the click&drag?

function preview(img, selection) {
    var scaleX = 100 / (selection.width || 1);
    var scaleY = 100 / (selection.height || 1);


    $('#preview + div > img').css({
        width: Math.round(scaleX * 400) + 'px',
        height: Math.round(scaleY * 300) + 'px',
        marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
        marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'

    });

}

$(document).ready(function () {
    $('<div><img src="http://odyniec.net/projects/imgareaselect/ferret.jpg" style="position: relative;" /><div>')
        .css({
            float: 'left',
            position: 'relative',
            overflow: 'hidden',
            width: '100px',
            height: '100px'
        })
        .insertAfter($('#preview'));

    $('#preview').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div>
    <img title="A ladybug being harassed by an ant." alt="A ladybug being harassed by an ant." src="http://odyniec.net/projects/imgareaselect/ferret.jpg" id="preview">
</div>
Micael Florêncio
  • 407
  • 1
  • 5
  • 11

0 Answers0