使用 ghosting 选项进行拖放

说明

此选项用于确定是否应克隆可拖动元素以进行拖动,将原始元素保留在原处直到克隆元素被放下。默认为 false。

当重影设置为 true 时,拖动操作似乎会将原始目标元素保留在原处,而拖动元素的半透明版本。

语法

以下是使用 ghosting 选项的简单语法。

new Draggable('element', {ghosting: true or false });

示例

<html>
   <head>
      <title>Draggables Elements</title>
		
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>
      <script type = "text/javascript" src = "/javascript/scriptaculous.js"></script>
		
      <script type = "text/javascript">
         window.onload = function() {
            new Draggable('myimage', {ghosting:true});
         }
      </script>
   </head>

   <body>
      <p>Try to drag following image and see how it leaves it
         original image at its place. Later change ghosting to false
         and repeat the exercise</p>
      <img id = "myimage" src = "/images/scriptaculous.gif"/>
   </body>
</html>

这将产生以下结果 −

scriptaculous_drag_drop.html