½ÃÀÛÆäÀÌÁö·Î Áñ°Üã±âÃß°¡
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ l Ã⼮üũ l ¸¶ÀÌÆäÀÌÁö l CGIMALL
happycgi
ÀÚ·á½Ç »çÀÌÆ®µî·Ï ·©Å·100 ÇÁ·Î±×·¥¸®ºä °ü¸®ÀÚÃßõÀÚ·á Ãʺ¸°¡À̵å
Ä¿¹Â´ÏƼ
Àüü ÆîÃ帱â
Äü¸Þ´º¸µÅ© jquery , CSS , PHP , Javascript , ¹«·áÆùÆ® , ASP
»ó¼¼°Ë»ö
Ȩ > JAVASCRIPT > javascript ¼Ò½ºÃ¢°í > µå·¹±×¿£µå·Ó > Drag And Drop »ó¼¼Á¤º¸
»çÀÌÆ®µî·Ï
Ŭ¶ó¿ìµåű×
Javascript
PHP
asp
CSS
html
mysql
jquery
image
Mobile
API
slide
°Ô½ÃÆÇ
¸Þ´º
ÇöÀçÁ¢¼ÓÀÚ ¸í »õ·Î°íħ
Drag And Drop
¼Ò½ºÅë°èÁ¤º¸ ¿À·ù½Å°í ¹× ¹®ÀÇ
ÇØÇÇÆÀ
³×ƼÁð
Æ®À§ÅÍ·Î º¸³»±â ÆäÀ̽ººÏÀ¸·Î º¸³»±â
¼Ò½ººÐ·ù µå·¹±×¿£µå·Ó
´Ù¿î·Îµå Ƚ¼ö 938 ȸ
°£´Ü¼³¸í ¸¶¿ì½º·Î ·¹À̾ µå·¡±× ¾Ø µå·Ó È¿°ú¸¦ ³À´Ï´Ù.
Æò°¡Çϱâ ÈǸ¢ÇÔ ¸Å¿ìÁÁÀ½ ÁÁÀ½ ±¦ÂúÀ½ º¸Åë º°·Î
ȨÆäÀÌÁö¹Ù·Î°¡±â ¼Ò½º´Ù¿î·Îµå µ¥¸ð ¹Ì¸®º¸±â ½ºÅ©·¦Çϱâ

[JS]

var DragHandler = {
 // private property.
 _oElem : null,


 // public method. Attach drag handler to an element.
 attach : function(oElem) {
  oElem.onmousedown = DragHandler._dragBegin;

  // callbacks
  oElem.dragBegin = new Function();
  oElem.drag = new Function();
  oElem.dragEnd = new Function();

  return oElem;
 },


 // private method. Begin drag process.
 _dragBegin : function(e) {
  var oElem = DragHandler._oElem = this;

  if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
  if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }

  var x = parseInt(oElem.style.left);
  var y = parseInt(oElem.style.top);

  e = e ? e : window.event;
  oElem.mouseX = e.clientX;
  oElem.mouseY = e.clientY;

  oElem.dragBegin(oElem, x, y);

  document.onmousemove = DragHandler._drag;
  document.onmouseup = DragHandler._dragEnd;
  return false;
 },


 // private method. Drag (move) element.
 _drag : function(e) {
  var oElem = DragHandler._oElem;

  var x = parseInt(oElem.style.left);
  var y = parseInt(oElem.style.top);

  e = e ? e : window.event;
  oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
  oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';

  oElem.mouseX = e.clientX;
  oElem.mouseY = e.clientY;

  oElem.drag(oElem, x, y);

  return false;
 },


 // private method. Stop drag process.
 _dragEnd : function() {
  var oElem = DragHandler._oElem;

  var x = parseInt(oElem.style.left);
  var y = parseInt(oElem.style.top);

  oElem.dragEnd(oElem, x, y);

  document.onmousemove = null;
  document.onmouseup = null;
  DragHandler._oElem = null;
 }

}


[HTML]


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 <head>
     <title>DEMO: Javascript drag handler</title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <link media="screen" type="text/css" rel="stylesheet" href="/demo/screen.css" />

 


  <script type="text/javascript" src="webtoolkit.drag.js"></script>
 </head>
 <body>

 <div id="container">


<div id="info">Start drag process...</div>
<div id="dragable1" style="position: relative; width: 50px; height: 50px; background: silver; border: 1px dashed red;"></div>
<div id="dragable2" style="position: relative; width: 60px; height: 60px; background: silver; border: 1px dashed red;"></div>
<div id="dragable3" style="position: relative; width: 70px; height: 70px; background: silver; border: 1px dashed red;"></div>

<script type="text/javascript">

 function begin (element, x, y) {
  var s = '#' + element.id + ' (begin drag)' + ' x:' + x + ', y:' + y;
  updateInfo(s);
 }

 function drag (element, x, y) {
  var s = '#' + element.id + ' (dragging)' + ' x:' + x + ', y:' + y;
  updateInfo(s);
 }

 function end (element, x, y) {
  var s = '#' + element.id + ' (end drag)' + ' x:' + x + ', y:' + y;
  updateInfo(s);
 }

 function updateInfo(s) {
  document.getElementById('info').innerHTML = s;
 }

 var dragable1 = DragHandler.attach(document.getElementById('dragable1'));
 var dragable2 = DragHandler.attach(document.getElementById('dragable2'));
 var dragable3 = DragHandler.attach(document.getElementById('dragable3'));

 dragable1.dragBegin = begin;
 dragable1.drag = drag;
 dragable1.dragEnd = end;

 dragable2.dragBegin = begin;
 dragable2.drag = drag;
 dragable2.dragEnd = end;

 dragable3.dragBegin = begin;
 dragable3.drag = drag;
 dragable3.dragEnd = end;

</script>


 </body>
</html>


³×ƼÁð ÀÇ°ß   ÀÌ¿ëÇϽŠÀÚ·áÀÇ Èı⸦ ÀÚÀ¯·Ó°Ô ÀÛ¼ºÇϼ¼¿ä. (»ó¾÷ÀûÀÎ ±¤°í ¹× µµ¹è¼º ±Û µîÀº »çÀüÅ뺸¾øÀÌ »èÁ¦µÉ ¼ö ÀÖ½À´Ï´Ù.)
³»¿ë ¾ÆÀ̵ð ÀÇ°ß³²±â±â
µî·ÏµÈ ÀÇ°ßÀÌ ¾ø½À´Ï´Ù.
1
À̸§
³»¿ë
:³×¸Â¾Æ¿ä: :È­³ª´Â±º¿ä: :Àá¿Í: :¿ì¿ïÇØ: :À̰ǾƳÄ: :¿ÕÇÏÇÏ: ¿Õ¿ôÀ½~ ³î·¥~
Æò°¡Çϱâ ÈǸ¢ÇÔ ¸Å¿ìÁÁÀ½ ÁÁÀ½ ±¦ÂúÀ½ º¸Åë º°·Î
µµ¹è¹æÁöÅ°
 89534333 º¸ÀÌ´Â µµ¹è¹æÁöÅ°¸¦ ÀÔ·ÂÇϼ¼¿ä.