Foros del Web » Programando para Internet » Jquery »

Problemas con Drag

Estas en el tema de Problemas con Drag en el foro de Jquery en Foros del Web. Buenos días Estoy utilizando este ejercicio: http://www.dhtmlgoodies.com/scripts/...ag-drop-3.html Con algunos ajustes asi: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código HTML: Ver original <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> < ...
  #1 (permalink)  
Antiguo 28/10/2013, 09:37
Avatar de ceaped  
Fecha de Ingreso: febrero-2004
Mensajes: 2.185
Antigüedad: 20 años, 2 meses
Puntos: 9
Pregunta Problemas con Drag

Buenos días
Estoy utilizando este ejercicio:

http://www.dhtmlgoodies.com/scripts/...ag-drop-3.html

Con algunos ajustes asi:

Código HTML:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2.  
  3.     <title>Título</title>
  4.    
  5.     <link rel="stylesheet" href="css/style.css" media="screen" type="text/css">
  6.        
  7.     <script type="text/javascript" src="js/drag-drop-custom.js"></script>
  8.    
  9. </head>
  10.  
  11.  
  12.    
  13.     <div id="container">
  14.         <h2>Texto...</h2>
  15.        
  16.     <div id="contenedor_preguntas">
  17.    
  18.         <div class="pregunta_1">
  19.         <div class="campo_texto">Texto 1</div>
  20.         <div class="dragableBox_1" id="box1">Pregunta 1
  21.         </div></div>
  22.        
  23.         <div class="pregunta_2">
  24.         <div class="campo_texto">Texto 2</div>
  25.         <div class="dragableBox_2" id="box2">Pregunta 2
  26.         </div></div>
  27.            
  28.     </div>
  29.        
  30.     <div id="respuestas">
  31.     <div id="box101" class="dragableBoxRight" title="Ubique aca la respuesta"><p>Respuesta 1</p></div>
  32.     <div id="box102" class="dragableBoxRight" title="Ubique aca la respuesta"><p>Respuesta 2</p></div>
  33.     </div>
  34.  
  35.  
  36. <script type="text/javascript">
  37.  
  38. function dropItems(idOfDraggedItem,targetId,x,y)
  39. {
  40.     var targetObj = document.getElementById(targetId);
  41.     var subDivs = targetObj.getElementsByTagName('DIV');
  42.     if(subDivs.length>0 && targetId!='contenedor_preguntas')return;
  43.     var sourceObj = document.getElementById(idOfDraggedItem);
  44.     var numericIdTarget = targetId.replace(/[^0-9]/gi,'')/1;
  45.     var numericIdSource = idOfDraggedItem.replace(/[^0-9]/gi,'')/1;
  46.     if(numericIdTarget-numericIdSource==100){
  47.                                                
  48.         sourceObj.style.backgroundColor='#0F0';
  49.     }else{
  50.         sourceObj.style.backgroundColor='';
  51.     }
  52.    
  53.     if(targetId=='contenedor_preguntas'){
  54.         targetObj = targetObj.getElementsByTagName('DIV')[0];  
  55.     }
  56.    
  57.     targetObj.appendChild(sourceObj);
  58. }
  59.  
  60. var dragDropObj = new DHTMLgoodies_dragDrop();
  61.  
  62. dragDropObj.addSource('box1',true);
  63. dragDropObj.addSource('box2',true);
  64.  
  65.  
  66. dragDropObj.addTarget('box101','dropItems');
  67. dragDropObj.addTarget('box102','dropItems');
  68. dragDropObj.addTarget('contenedor_preguntas','dropItems');
  69.  
  70. dragDropObj.init();
  71.  
  72.  
  73. </body>
  74. </html>

Y el css:

Código CSS:
Ver original
  1. #contenedor_preguntas{
  2.     width:945px;
  3.     height:440px;
  4.     margin-top: 0px;
  5.     margin-right: auto;
  6.     margin-bottom: 0px;
  7.     margin-left: auto;
  8.     border: thin solid #F00;
  9.     }
  10.        
  11. .pregunta_1{
  12.     width:234px;
  13.     height:360px;
  14.     float:left;
  15.     background-color:#FCF;
  16.     margin-top: 0px;
  17.     margin-right: auto;
  18.     margin-bottom: 0px;
  19.     margin-left: auto;
  20.     }
  21.    
  22. .pregunta_2{
  23.     width:234px;
  24.     height:360px;
  25.     float:left;
  26.     background-color:#C33;
  27.     margin-top: 0px;
  28.     margin-right: auto;
  29.     margin-bottom: 0px;
  30.     margin-left: auto;
  31.     }
  32.    
  33. #respuestas{
  34.     width:945px;
  35.     height:80px;
  36.     margin-top: 10px;
  37.     margin-right: 5px;
  38.     margin-bottom: 0px;
  39.     margin-left: 5px;
  40.     position: absolute;
  41.     float: left;
  42.     border: 1px solid #000;
  43.     }
  44.  
  45. .campo_texto{
  46.     width:225px;
  47.     height:350px;
  48.     z-index: 1;
  49.     margin-top: 5px;
  50.     margin-right: auto;
  51.     margin-bottom: 10px;
  52.     margin-left: auto;
  53.     font-family: Arial, Helvetica, sans-serif;
  54.     font-size: 1em;
  55.     color: #000;
  56.     text-align: justify;
  57.     }
  58.  
  59. .dragableBoxRight{
  60.     width:225px;
  61.     height:65px;
  62.     background-color:#C9F;
  63.     text-align:center;
  64.     margin-top: 0px;
  65.     margin-right: auto;
  66.     margin-bottom: 0px;
  67.     margin-left: 200px;
  68.     position: relative;
  69.     line-height: 60px;
  70.     }
  71.  
  72. .dragableBox_1{
  73.     width:225px;
  74.     height:65px;
  75.     background-color:#FCF;
  76.     text-align:center;
  77.     position: relative;
  78.     line-height: 60px;
  79.     z-index: 1;
  80.     }
  81.    
  82. .dragableBox_2{
  83.     width:225px;
  84.     height:65px;
  85.     background-color:#C33;
  86.     text-align:center;
  87.     position: relative;
  88.     line-height: 60px;
  89.     z-index: 1;
  90.     }
  91.    
  92. div.dragableBoxRight{
  93.     height:65px;
  94.     width:225px;
  95.     background-color:#CCC;
  96.     float: left;
  97.     margin: 5px;
  98.     line-height: 50px;
  99.     }
El funciona bien, el problema es que si devuelvo la pregunta 2 a su posición inicial se pega de la pregunta 1 y deseo que se devuelva a su posición inicial.

¿Cómo puedo hacerlo?

Gracias por su ayuda
__________________
Diseñador Gráfico publicitario

Etiquetas: drag
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:14.