Script.aculo.us-scriptaculous-revert-example

提供:Dev Guides
移動先:案内検索

復帰オプション付きのドラッグアンドドロップ

説明

trueに設定すると、要素はドラッグが終了すると元の位置に戻ります。 また、ドラッグ操作が停止したときに_reverteffect_コールバックを呼び出すかどうかも指定します。 デフォルトはfalseです。

構文

_revert_オプションを設定する簡単な構文を次に示します。

new Draggable('element', {revert:true});

<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', {revert:true} );
         }
      </script>
   </head>

   <body>
      <p>Drag it and then leave it to see the result:</p>
      <img id = "myimage" src = "/images/scriptaculous.gif"/>
   </body>
</html>

これにより、次の結果が生成されます–