Javascript Resize and drag classes, based on jquery

Source: Internet
Author: User

Some time ago wrote a "online picture cutting" Small program, now the resize and drag action as a separate class separate, and share with you. All two classes require jquery support, but it should be easy to rewrite the non-jquery version. In addition, the resize class is similar to the code for the drag class and should be easily integrated into a class if you want to. A willing friend can try. Welcome to Pat Bricks and make suggestions:)

Use

Click here to see the demo effect.

Use Resize and Drag

$(function(){
    var sa = document.getElementById('selectArea');
    $('#selectArea span').mousedown(function(e){
        new Resize(sa).start(e, this.className.replace('-resize', ''));
    });
    $('#selectArea').mousedown(function(e){
        new Drag(sa).start(e);
    });
});

The following is the HTML section:

Demo HTML

<div style="margin:30px 100px;position:relative;height:500px;border:1px solid #000;background-color:#EEE;">
this is wrapper.

    <div id="selectArea" style="left:100px;top:80px;width:150px;height:100px; background-color:#CCC;">
    <span class="north-west-resize"></span><span class="north-resize"></span><span class="north-east-resize"></span>
    <span class="west-resize"> </span>                                   <span class="east-resize"> </span>
    <span class="south-west-resize"></span><span class="south-resize"></span><span class="south-east-resize"></span>
    you can resize and drag this box.
    </div>
</div>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.