zoukankan      html  css  js  c++  java
  • easyui Draggable

    Draggable

    Override defaults with $.fn.draggable.defaults.

    Usage Example

    Create a draggable element from markup.

    1. <divid="dd"class="easyui-draggable"data-options="handle:'#title'"style="width:100px;height:100px;">
    2. <divid="title"style="background:#ccc;">title</div>
    3. </div>

    Create a draggable element using javascript.

    1. <divid="dd"style="width:100px;height:100px;">
    2. <divid="title"style="background:#ccc;">title</div>
    3. </div>
    1. $('#dd').draggable({
    2. handle:'#title'
    3. });

    Properties

    NameTypeDescriptionDefault
    proxy null或string(比如'clone')或function A proxy element to be used when dragging, when set to 'clone', a clone element is used as proxy. If a function is specified, it must return a jQuery object.

    The example below shows how to create a simple proxy object.

    //1.默认是null

    //2. 可用'clone'
    $('.dragitem').draggable({ proxy: 'clone' });


    //3. 可用function
    $('.dragitem').draggable({ proxy: function(source){ var p = $('<div style="border:1px solid #ccc;80px"></div>'); p.html($(source).html()).appendTo('body'); return p; } });


    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Basic Draggable - jQuery EasyUI Demo</title>
        <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
        <link rel="stylesheet" type="text/css" href="../demo.css">
        <script type="text/javascript" src="../../jquery.min.js"></script>
        <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
    
        <script>
        $(function(){
            //从此以后,光标都是文本光标了
            //$.fn.draggable.defaults.cursor = 'text';
            
            $('#dd').draggable({
                proxy : function(source){
                    //console.log(source);
                    
                    var p = $('<div style="border:1px solid #ccc;height:'+ source.style.height + ';'+source.style.width+'"></div>');
                    //console.log(p.html($(source).html()));
                    p.html($(source).html()).appendTo('body');
                    return p;
    
                }
            });
        });
        </script>
    </head>
    <body>
        <div id="dd" style="100px;height:100px;background:green">
        wosout
        </div>
    </body>
    </html>
    View Code


    null
    revert boolean If set to true, the element will return to its start position when dragging stops. false
    cursor string

    The css cursor when dragging.

    可能的值

    描述
    url

    需使用的自定义光标的 URL。

    注释:请在此列表的末端始终定义一种普通的光标,以防没有由 URL 定义的可用光标。

    default 默认光标(通常是一个箭头)
    auto 默认。浏览器设置的光标。
    crosshair 光标呈现为十字线。
    pointer 光标呈现为指示链接的指针(一只手)
    move 此光标指示某对象可被移动。
    e-resize 此光标指示矩形框的边缘可被向右(东)移动。
    ne-resize 此光标指示矩形框的边缘可被向上及向右移动(北/东)。
    nw-resize 此光标指示矩形框的边缘可被向上及向左移动(北/西)。
    n-resize 此光标指示矩形框的边缘可被向上(北)移动。
    se-resize 此光标指示矩形框的边缘可被向下及向右移动(南/东)。
    sw-resize 此光标指示矩形框的边缘可被向下及向左移动(南/西)。
    s-resize 此光标指示矩形框的边缘可被向下移动(南)。
    w-resize 此光标指示矩形框的边缘可被向左移动(西)。
    text 此光标指示文本。
    wait 此光标指示程序正忙(通常是一只表或沙漏)。
    help 此光标指示可用的帮助(通常是一个问号或一个气球)。

     

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Basic Draggable - jQuery EasyUI Demo</title>
     6     <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
     7     <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
     8     <link rel="stylesheet" type="text/css" href="../demo.css">
     9     <script type="text/javascript" src="../../jquery.min.js"></script>
    10     <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
    11 
    12     <script>
    13     $(function(){
    14         $('#dd').draggable({
    15             cursor:'wait',//光标变成等待
    16             handle:'#title' //拖动标题div时
    17         });
    18     });
    19     </script>
    20 </head>
    21 <body>
    22     <div id="dd" style="100px;height:100px;">
    23         <div id="title" style="background:#ccc;">title</div>
    24         <div id="content" style="80px;height:80px;background:red"></div>
    25     </div>
    26 </body>
    27 </html>
    View Code
    move
    deltaX number The dragged element position x corresponding to current cursor null
    deltaY number The dragged element position y corresponding to current cursor null
    handle selector The handle that start the draggable. null
    disabled boolean True to stop draggable. false
    edge number The drag width in which can start draggable. 0
    axis string Defines the axis which the dragged elements moves on, available value is 'v' or 'h', when set to null will move across 'v' and 'h' direction. null
    delay number Defines the delay time in milliseconds to start a drag operation. 100

    Events

    NameParametersDescription
    onBeforeDrag e Fires before dragging, return false to cancel this dragging.
    onStartDrag e Fires when the target object start dragging.
    onDrag e Fires during dragging. Return false will not do dragging actually.
    onStopDrag e Fires when the dragging stops.

    Methods

    NameParameterDescription
    options none Return the options property.
    proxy none Return the drag proxy if the proxy property is setted.
    enable none Enable the drag action.
    disable none Disable the drag action.
  • 相关阅读:
    摘抄博文
    html5中getContext()方法和CanvasRenderingContext2D对象详解
    三十四、Android Spinner控件之键值对用法
    二十七、Android之GPS定位详解
    J2EE用监听器实现同一用户只能有一个在线
    三十二、Android上传文件至服务器
    二十六、Android WebView缓存
    三十九、Android原理 不需要关闭后台运行程序
    三十七、android sqlite3详解
    struts2之注解权限控制
  • 原文地址:https://www.cnblogs.com/yasepix/p/6437309.html
Copyright © 2011-2022 走看看