防止在ImgAreaSelect上单击并拖动

时间:2015-01-12 10:16:06

标签: javascript jquery html css

我尝试在此处重现示例http://jsfiddle.net/uydpr/2/,因为代码位于我的页面内,但是不会让图像区域被选中,而是将图像视为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 });
&#13;
<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>
&#13;
&#13;
&#13;

0 个答案:

没有答案