Script.aculo.us-scriptaculous-revert-example

提供:Dev Guides
2020年6月23日 (火) 11:22時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

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

説明

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>

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