aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/api/dragevent
diff options
context:
space:
mode:
Diffstat (limited to 'files/de/web/api/dragevent')
-rw-r--r--files/de/web/api/dragevent/index.html239
1 files changed, 239 insertions, 0 deletions
diff --git a/files/de/web/api/dragevent/index.html b/files/de/web/api/dragevent/index.html
new file mode 100644
index 0000000000..4f6ec7b562
--- /dev/null
+++ b/files/de/web/api/dragevent/index.html
@@ -0,0 +1,239 @@
+---
+title: DragEvent
+slug: Web/API/DragEvent
+translation_of: Web/API/DragEvent
+---
+<div>{{APIRef("HTML DOM")}}</div>
+
+<p>Das <code>drag</code> Event wird ausgelöst, wenn ein Element oder ein Text "gezogen" wird (alle paar hundert Millisekunden).</p>
+
+<h2 id="Allgemeine_Informationen">Allgemeine Informationen</h2>
+
+<dl>
+ <dt style="float: left; text-align: right; width: 120px;">Spezifikation</dt>
+ <dd style="margin: 0 0 0 120px;"><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-drag">HTML5</a></dd>
+ <dt style="float: left; text-align: right; width: 120px;">Interface</dt>
+ <dd style="margin: 0 0 0 120px;">DragEvent</dd>
+ <dt style="float: left; text-align: right; width: 120px;">Steigt auf</dt>
+ <dd style="margin: 0 0 0 120px;">Ja</dd>
+ <dt style="float: left; text-align: right; width: 120px;">Abbrechbar</dt>
+ <dd style="margin: 0 0 0 120px;">Ja</dd>
+ <dt style="float: left; text-align: right; width: 120px;">Ziel</dt>
+ <dd style="margin: 0 0 0 120px;">Document, Element</dd>
+ <dt style="float: left; text-align: right; width: 120px;">Standard-Aktion</dt>
+ <dd style="margin: 0 0 0 120px;">Mit der drag &amp; drop Operation fortfahren.</dd>
+</dl>
+
+<h2 id="Eigenschaften">Eigenschaften</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Property</th>
+ <th scope="col">Type</th>
+ <th scope="col">Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>target</code> {{readonlyInline}}</td>
+ <td><a href="/en-US/docs/Web/API/EventTarget" title="EventTarget is an interface implemented by objects that can receive events and may have listeners for them."><code>EventTarget</code></a></td>
+ <td>The element that was underneath the element being dragged.</td>
+ </tr>
+ <tr>
+ <td><code>type</code> {{readonlyInline}}</td>
+ <td><a href="/en-US/docs/Web/API/DOMString" title="DOMString is a UTF-16 String. As JavaScript already uses such strings, DOMString is mapped directly to a String."><code>DOMString</code></a></td>
+ <td>The type of event.</td>
+ </tr>
+ <tr>
+ <td><code>bubbles</code> {{readonlyInline}}</td>
+ <td><a href="/en-US/docs/Web/API/Boolean" title="The Boolean object is an object wrapper for a boolean value."><code>Boolean</code></a></td>
+ <td>Whether the event normally bubbles or not</td>
+ </tr>
+ <tr>
+ <td><code>cancelable</code> {{readonlyInline}}</td>
+ <td><a href="/en-US/docs/Web/API/Boolean" title="The Boolean object is an object wrapper for a boolean value."><code>Boolean</code></a></td>
+ <td>Whether the event is cancellable or not?</td>
+ </tr>
+ <tr>
+ <td><code>view</code> {{readonlyInline}}</td>
+ <td><a class="new" href="/en-US/docs/Web/API/WindowProxy" rel="nofollow" title="The documentation about this has not yet been written; please consider contributing!"><code>WindowProxy</code></a></td>
+ <td><a href="/en-US/docs/Web/API/Document/defaultView" title="In browsers, document.defaultView returns the window object associated with a document, or null if none is available."><code>document.defaultView</code></a> (<code>window</code> of the document)</td>
+ </tr>
+ <tr>
+ <td><code>detail</code> {{readonlyInline}}</td>
+ <td><code>long</code> (<code>float</code>)</td>
+ <td>0.</td>
+ </tr>
+ <tr>
+ <td><code>dataTransfer</code></td>
+ <td>DataTransfer</td>
+ <td>The data that underlies a drag-and-drop operation, known as the <a href="/en-US/docs/Web/API/DataTransfer">drag data store</a>. Protected mode.</td>
+ </tr>
+ <tr>
+ <td><code>currentTarget</code> {{readonlyInline}}</td>
+ <td>EventTarget</td>
+ <td>The node that had the event listener attached.</td>
+ </tr>
+ <tr>
+ <td><code>relatedTarget</code> {{readonlyInline}}</td>
+ <td>EventTarget</td>
+ <td>For <code>mouseover</code>, <code>mouseout</code>, <code>mouseenter</code> and <code>mouseleave</code> events: the target of the complementary event (the <code>mouseleave</code> target in the case of a <code>mouseenter</code> event). <code>null</code> otherwise.</td>
+ </tr>
+ <tr>
+ <td><code>screenX</code> {{readonlyInline}}</td>
+ <td>long</td>
+ <td>The X coordinate of the mouse pointer in global (screen) coordinates.</td>
+ </tr>
+ <tr>
+ <td><code>screenY</code> {{readonlyInline}}</td>
+ <td>long</td>
+ <td>The Y coordinate of the mouse pointer in global (screen) coordinates.</td>
+ </tr>
+ <tr>
+ <td><code>clientX</code> {{readonlyInline}}</td>
+ <td>long</td>
+ <td>The X coordinate of the mouse pointer in local (DOM content) coordinates.</td>
+ </tr>
+ <tr>
+ <td><code>clientY</code> {{readonlyInline}}</td>
+ <td>long</td>
+ <td>The Y coordinate of the mouse pointer in local (DOM content) coordinates.</td>
+ </tr>
+ <tr>
+ <td><code>button</code> {{readonlyInline}}</td>
+ <td>unsigned short</td>
+ <td>The button number that was pressed when the mouse event was fired: Left button=0, middle button=1 (if present), right button=2. For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left.</td>
+ </tr>
+ <tr>
+ <td><code>buttons</code> {{readonlyInline}}</td>
+ <td>unsigned short</td>
+ <td>The buttons being pressed when the mouse event was fired: Left button=1, Right button=2, Middle (wheel) button=4, 4th button (typically, "Browser Back" button)=8, 5th button (typically, "Browser Forward" button)=16. If two or more buttons are pressed, returns the logical sum of the values. E.g., if Left button and Right button are pressed, returns 3 (=1 | 2). <a href="/en-US/docs/Web/API/MouseEvent">More info</a>.</td>
+ </tr>
+ <tr>
+ <td><code>mozPressure</code> {{readonlyInline}}</td>
+ <td>float</td>
+ <td>The amount of pressure applied to a touch or tabdevice when generating the event; this value ranges between 0.0 (minimum pressure) and 1.0 (maximum pressure).</td>
+ </tr>
+ <tr>
+ <td><code>ctrlKey</code> {{readonlyInline}}</td>
+ <td>boolean</td>
+ <td><code>true</code> if the control key was down when the event was fired. <code>false</code> otherwise.</td>
+ </tr>
+ <tr>
+ <td><code>shiftKey</code> {{readonlyInline}}</td>
+ <td>boolean</td>
+ <td><code>true</code> if the shift key was down when the event was fired. <code>false</code> otherwise.</td>
+ </tr>
+ <tr>
+ <td><code>altKey</code> {{readonlyInline}}</td>
+ <td>boolean</td>
+ <td><code>true</code> if the alt key was down when the event was fired. <code>false</code> otherwise.</td>
+ </tr>
+ <tr>
+ <td><code>metaKey</code> {{readonlyInline}}</td>
+ <td>boolean</td>
+ <td><code>true</code> if the meta key was down when the event was fired. <code>false</code> otherwise.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Beispiel">Beispiel</h2>
+
+<pre class="brush: js">&lt;div class="dropzone"&gt;
+    &lt;div id="draggable" draggable="true" ondragstart="event.dataTransfer.setData('text/plain',null)"&gt;
+        This div is draggable
+    &lt;/div&gt;
+&lt;/div&gt;
+&lt;div class="dropzone"&gt;&lt;/div&gt;
+&lt;div class="dropzone"&gt;&lt;/div&gt;
+&lt;div class="dropzone"&gt;&lt;/div&gt;
+
+&lt;style&gt;
+ #draggable {
+ width: 200px;
+ height: 20px;
+ text-align: center;
+ background: white;
+ }
+
+ .dropzone {
+ width: 200px;
+ height: 20px;
+ background: blueviolet;
+ margin-bottom: 10px;
+ padding: 10px;
+ }
+&lt;/style&gt;
+
+&lt;script&gt;
+ <span>var dragged;
+
+ /* Event wird vom ge-drag-ten Element ausgelöst */
+ document.addEventListener("drag", function( event ) {
+
+ }, false);
+
+ document.addEventListener("dragstart", function( event ) {
+ // Speichern einer ref auf das drag-bare Element
+ dragged = event.target;
+ // Element halb-transparent machen
+ event.target.style.opacity = .5;
+ }, false);
+
+ document.addEventListener("dragend", function( event ) {
+ // Transparenz zurücksetzen
+ event.target.style.opacity = "";
+ }, false);
+
+ /* events fired on the drop targets */
+ document.addEventListener("dragover", function( event ) {
+ // Standard-Aktion verhindern um das drop-Event zu erlauben
+ event.preventDefault();
+ }, false);
+
+ document.addEventListener("dragenter", function( event ) {
+ // Hintergrund des möglichen Drop-Zeils anfärben, wenn das drag-bare Element auf das Ziel gezogen wird
+ if ( event.target.className == "dropzone" ) {
+ event.target.style.background = "purple";
+ }
+
+ }, false);
+
+ document.addEventListener("dragleave", function( event ) {
+ // Hintergrund des möglichen Drop-Ziels, wenn das drag-bare Element vom Ziel wieder weggezogen wird / verlässt
+ if ( event.target.className == "dropzone" ) {
+ event.target.style.background = "";
+ }
+ }, false);
+
+ document.addEventListener("drop", function( event ) {
+ // Standard-Aktion verhindern (Bei einigen Elementen wäre das das Öffnen als Link)
+ event.preventDefault();
+ // move dragged elem to the selected drop target
+ if ( event.target.className == "dropzone" ) {
+ event.target.style.background = "";
+ dragged.parentNode.removeChild( dragged );
+ event.target.appendChild( dragged );
+ }
+
+ }, false);</span>
+&lt;/script&gt;
+</pre>
+
+<h2 id="Verwandte_Events">Verwandte Events</h2>
+
+<p> </p>
+
+<ul>
+ <li>{{event("drag")}}</li>
+ <li>{{event("dragstart")}}</li>
+ <li>{{event("dragend")}}</li>
+ <li>{{event("dragover")}}</li>
+ <li>{{event("dragenter")}}</li>
+ <li>{{event("dragleave")}}</li>
+ <li>{{event("dragexit")}}</li>
+ <li>{{event("drop")}}</li>
+</ul>
+
+<p> </p>