Resizable, draggable object in jquery. Possible?

后端 未结 2 371
滥情空心
滥情空心 2021-01-14 16:39

I want to have an object which is both resizable and draggable. I\'ll need:

  • X
  • Y
  • Size

of the object.

Is this possible?

2条回答
  •  醉话见心
    2021-01-14 16:50

    If you mean draggable, that something like this:

    $( "#elem" ).resizable().draggable();
    

    Size and position you can point with css (first time). Than you can change them and get (when you resize or move) with jQuery.

    You can add options to draggable() and resizable() methods. Reference is here: http://jqueryui.com/demos/resizable/ and http://jqueryui.com/demos/draggable/

    P.S. This code requires jquery-ui.js file and jquery-ui.css (because it draws a marker to resize)

    P.P.S.

    With your link: In JavaScript frame I added the line:

    $('#dropHere').resizable();
    

    And I added css-style in managed resources "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/themes/base/jquery-ui.css"

    And it worked!

提交回复
热议问题