【jQwidgets】dragdrop 修改版

系统管理员 2022-08-06 11:10 247阅读 0赞

jqxdragdrop dragdrop-events.htm

http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdragdrop/dragdrop-events.htm?arctic

修改版:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta name="keywords" content="jqxDragDrop, jQuery Draggable, jQWidgets, Events Demo" />
  5. <meta name="description" content="You can restrict draggables drag area in different ways. In this demo the dragging area of the draggable element is it's parent." />
  6. <title id='Description'>In this demo is demonstrated how to use the jqxDragDrop plug-in events.</title>
  7. <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
  8. <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
  9. <script type="text/javascript" src="../../scripts/demos.js"></script>
  10. <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
  11. <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script>
  12. <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
  13. <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
  14. <script type="text/javascript" src="../../jqwidgets/jqxdragdrop.js"></script>
  15. <script type="text/javascript">
  16. $(document).ready(function () {
  17. var istag=false;
  18. $('#events').jqxPanel({ width: 260, height: 330});
  19. $('#draggable').jqxDragDrop({ restricter: 'parent', dropTarget: '.drop-target',revert:false });
  20. $('#draggable').bind('dragStart', function (event) {
  21. addEvent(event.type, event.args.position);
  22. });
  23. $('#draggable').bind('dragEnd', function (event) {
  24. addEvent(event.type, event.args.position);
  25. if(!istag){
  26. $('#draggable').animate({
  27. 'left': '0px',
  28. 'top': '0px'},
  29. 500, function() {
  30. });
  31. }else{
  32. $('#draggable').animate({
  33. 'left': '200px',
  34. 'top': '200px'},
  35. 500, function() {
  36. });
  37. }
  38. });
  39. $('#draggable').bind('dropTargetEnter', function (event) {
  40. addEvent(event.type, event.args.position);
  41. istag=true;
  42. $('#draggable').jqxDragDrop({revert:false });
  43. $('#draggable').animate({
  44. 'left': '200px',
  45. 'top': '200px'},
  46. 500, function() {
  47. });
  48. });
  49. $('#draggable').bind('dropTargetLeave', function (event) {
  50. addEvent(event.type, event.args.position);
  51. istag=false;
  52. /*$('#draggable').animate({
  53. 'left': '0px',
  54. 'top': '0px'},
  55. 500, function() {
  56. });*/
  57. });
  58. function addEvent(type, position) {
  59. $('#events').jqxPanel('prepend',
  60. '<div class="row">Event: ' + type + ', (' + position.left + ', ' + position.top + ')</div>'
  61. );
  62. }
  63. (function centerLabels() {
  64. var labels = $('.label');
  65. labels.each(function (index, el) {
  66. el = $(el);
  67. var top = (el.parent().height() - el.height()) / 2;
  68. el.css('top', top + 'px');
  69. });
  70. } ());
  71. });
  72. </script>
  73. <style type="text/css">
  74. .row
  75. {
  76. padding: 1px;
  77. }
  78. .draggable
  79. {
  80. border: 1px solid #bbb;
  81. background-color: #C9ECFF;
  82. width: 100px;
  83. height: 100px;
  84. left: 30px;
  85. top: 50px;
  86. padding: 5px;
  87. z-index: 2;
  88. }
  89. #draggable-parent
  90. {
  91. background-color: #eeffee;
  92. width: 350px;
  93. height: 350px;
  94. text-align: center;
  95. border: 1px solid #eee;
  96. float: left;
  97. }
  98. .main-container
  99. {
  100. width: 650px;
  101. z-index: 0;
  102. }
  103. .events
  104. {
  105. float: right;
  106. padding: 10px;
  107. font-family: Tahoma;
  108. font-size: 13px;
  109. }
  110. .label
  111. {
  112. position: relative;
  113. font-family: Verdana;
  114. font-size: 11px;
  115. color: #000;
  116. }
  117. .drop-target
  118. {
  119. background-color: #FBFFB5;
  120. width: 150px;
  121. height: 150px;
  122. border: 1px solid #ddd;
  123. margin-left: 190px;
  124. margin-top: 70px;
  125. z-index: 1;
  126. }
  127. </style>
  128. </head>
  129. <body class='default'>
  130. <div class="main-container">
  131. <div id="draggable-parent">
  132. <div id="draggable" class="draggable">
  133. <div class="label">I can be dragged only inside my parent</div>
  134. </div>
  135. <div class="drop-target"><div class="label">I'm a drop target</div></div>
  136. </div>
  137. <div id="events" class="events">
  138. </div>
  139. </div>
  140. </body>
  141. </html>

发表评论

表情:
评论列表 (有 0 条评论,247人围观)

还没有评论,来说两句吧...

相关阅读