diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/dragevent | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/dragevent')
-rw-r--r-- | files/zh-cn/web/api/dragevent/datatransfer/index.html | 120 | ||||
-rw-r--r-- | files/zh-cn/web/api/dragevent/dragevent/index.html | 113 | ||||
-rw-r--r-- | files/zh-cn/web/api/dragevent/index.html | 156 |
3 files changed, 389 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/dragevent/datatransfer/index.html b/files/zh-cn/web/api/dragevent/datatransfer/index.html new file mode 100644 index 0000000000..a4ed8f2ad0 --- /dev/null +++ b/files/zh-cn/web/api/dragevent/datatransfer/index.html @@ -0,0 +1,120 @@ +--- +title: DragEvent.dataTransfer +slug: Web/API/DragEvent/dataTransfer +translation_of: Web/API/DragEvent/dataTransfer +--- +<div>{{APIRef("HTML Drag and Drop API")}}</div> + +<div> </div> + +<p><code><strong>DataEvent.dataTransfer</strong></code> 属性保存着拖拽操作中的数据(作为一个DataTransfer对象)</p> + +<p>This property is {{readonlyInline}}.</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">var <var>data</var> = <var>dragEvent</var>.dataTransfer; +</pre> + +<h3 id="返回值">返回值</h3> + +<dl> + <dt><code>data</code></dt> + <dd>{{domxref("DataTransfer")}} 对象包含着 {{domxref("DragEvent","drag event's data")}}.</dd> +</dl> + +<h2 id="示例">示例</h2> + +<p>这个例子展示了在{{event("dragend")}} 事件处理程序中获取拖拽中数据的方式。</p> + +<pre class="brush: js">function process_data(d) { + // Process the data ... +} + +dragTarget.addEventListener("dragend", function(ev) { + // Call the drag and drop data processor + if (ev.dataTransfer != null) process_data(ev.dataTransfer); + }, false); +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName("HTML WHATWG", "interaction.html#dom-dragevent-datatransfer", "DragEvent.dataTransfer")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("HTML5.1", "editing.html#dom-dragevent-datatransfer", "DragEvent.dataTransfer")}}</td> + <td>{{Spec2("HTML5.1")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>Basic support</td> + <td>4</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("1.9.1")}}</td> + <td>10</td> + <td>12</td> + <td>3.1</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Android Webview</th> + <th>Chrome for Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>Firefox OS</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatIE("10")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> diff --git a/files/zh-cn/web/api/dragevent/dragevent/index.html b/files/zh-cn/web/api/dragevent/dragevent/index.html new file mode 100644 index 0000000000..8171ad04a4 --- /dev/null +++ b/files/zh-cn/web/api/dragevent/dragevent/index.html @@ -0,0 +1,113 @@ +--- +title: DragEvent() +slug: Web/API/DragEvent/DragEvent +translation_of: Web/API/DragEvent/DragEvent +--- +<div>{{APIRef("HTML Drag and Drop API")}}</div> + +<p>This constructor is used to create a synthetic {{domxref("DragEvent")}} object.</p> + +<p class="note">Although this interface has a constructor, it is not possible to create a useful {{domxref("DataTransfer")}} object from script, since {{domxref("DataTransfer")}} objects have a processing and security model that is coordinated by the browser during drag-and-drops.</p> + +<p class="note">该接口继承了 {{domxref("MouseEvent")}} 和 {{domxref("Event")}} 的属性。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"> <em>event</em> = new DragEvent(<em>type</em>, <em>DragEventInit</em>);</pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><em>type</em></dt> + <dd>Is a <code>{{domxref("DOMString")}}</code> representing the name of the event (see <a href="/Web/API/DragEvent#Event_types">DragEvent event types</a>).</dd> + <dt><em>DragEventInit</em>{{optional_inline}}</dt> +</dl> + +<dl> + <dd>Is a <code>DragEventInit</code> dictionary, having the following fields: + + <ul> + <li><code>"dataTransfer"</code>, optional and defaults to <code>"null"</code>. The type is <code>{{domxref("DataTransfer")}}</code>.</li> + </ul> + </dd> +</dl> + +<p class="note">The <code>DragEventInit</code> dictionary inherits from the {{domxref("MouseEvent.MouseEvent","MouseEventInit dictionary")}}.</p> + +<h2 id="标准">标准</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName("HTML WHATWG", "interaction.html#the-dragevent-interface", "DragEvent")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("HTML5.1", "editing.html#the-dragevent-interface", "DragEvent")}}</td> + <td>{{Spec2("HTML5.1")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>Basic support</td> + <td>4</td> + <td>{{CompatGeckoDesktop("1.9.1")}}</td> + <td>10</td> + <td>12</td> + <td>3.1</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Android Webview</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>Firefox OS</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatIE("10")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> diff --git a/files/zh-cn/web/api/dragevent/index.html b/files/zh-cn/web/api/dragevent/index.html new file mode 100644 index 0000000000..b95501000c --- /dev/null +++ b/files/zh-cn/web/api/dragevent/index.html @@ -0,0 +1,156 @@ +--- +title: DragEvent +slug: Web/API/DragEvent +translation_of: Web/API/DragEvent +--- +<div>{{APIRef("HTML Drag and Drop API")}}</div> + +<p><strong><code>DragEvent</code></strong> 是一个表示拖、放交互的一个{{domxref("Event","DOM event")}} 接口。用户通过将指针设备(例如鼠标)放置在触摸表面上并且然后将指针拖动到新位置(诸如另一个DOM元素)来发起拖动。 应用程序可以按应用程序特定的方式自由解释拖放交互。</p> + +<p class="note">这个接口继承 {{domxref("MouseEvent")}} 和{{domxref("Event")}}属性</p> + +<h2 id="属性">属性</h2> + +<dl> + <dt>{{domxref('DragEvent.dataTransfer')}} {{readonlyInline}}</dt> + <dd>在拖放交互期间传输的数据。</dd> +</dl> + +<h2 id="构造函数">构造函数</h2> + +<p class="note">虽然这个接口有一个构造函数,但不可能从脚本创建一个有用的 DataTransfer 对象,因为在拖放期间,有一个由浏览器分配的一个处理中和安全模式的{{domxref("DataTransfer")}}对象。</p> + +<dl> + <dt>{{domxref("DragEvent.DragEvent", "DragEvent()")}}</dt> + <dd>创建合成和不可信的 DragEvent.</dd> +</dl> + +<h2 id="事件类型">事件类型</h2> + +<dl> + <dt>{{event('drag')}}</dt> + <dd>拖动元素或选择文本时触发此事件。</dd> + <dt>{{event('dragend')}}</dt> + <dd>当拖动操作结束时(释放鼠标按钮或按下退出键),会触发此事件。</dd> + <dt>{{event('dragenter')}}</dt> + <dd>当拖动的元素或选择文本输入有效的放置目标时,会触发此事件。</dd> + <dt>{{event('dragexit')}}</dt> + <dd>当元素不再是拖动操作的选择目标时触发此事件。</dd> + <dt>{{event('dragleave')}}</dt> + <dd>当拖动的元素或文本选择离开有效的放置目标时,会触发此事件。</dd> + <dt>{{event('dragover')}}</dt> + <dd>当将元素或文本选择拖动到有效放置目标(每几百毫秒)上时,会触发此事件。</dd> + <dt>{{event('dragstart')}}</dt> + <dd>当用户开始拖动元素或选择文本时触发此事件。</dd> + <dt>{{event('drop')}}</dt> + <dd>当在有效放置目标上放置元素或选择文本时触发此事件。</dd> +</dl> + +<h2 id="全局事件处理">全局事件处理</h2> + +<dl> + <dt>{{domxref('GlobalEventHandlers.ondrag')}}</dt> + <dd>{{event('drag')}} 事件的{{domxref('GlobalEventHandlers','全局事件处理')}}。</dd> + <dt>{{domxref('GlobalEventHandlers.ondragend')}}</dt> + <dd>{{event('dragend')}} 事件的{{domxref('GlobalEventHandlers','全局事件处理')}}。</dd> + <dt>{{domxref('GlobalEventHandlers.ondragenter')}}</dt> + <dd>{{event('dragenter')}} 事件的{{domxref('GlobalEventHandlers','全局事件处理')}}。</dd> + <dt>{{domxref('GlobalEventHandlers.ondragexit')}}</dt> + <dd>{{event('dragexit')}} 事件的{{domxref('GlobalEventHandlers','全局事件处理')}}。</dd> + <dt>{{domxref('GlobalEventHandlers.ondragleave')}}</dt> + <dd>{{event('dragleave')}} 事件的{{domxref('GlobalEventHandlers','全局事件处理')}}。</dd> + <dt>{{domxref('GlobalEventHandlers.ondragover')}}</dt> + <dd>{{event('dragover')}} 事件的{{domxref('GlobalEventHandlers','全局事件处理')}}。</dd> + <dt>{{domxref('GlobalEventHandlers.ondragstart')}}</dt> + <dd>{{event('dragstart')}} 事件的{{domxref('GlobalEventHandlers','全局事件处理')}}。</dd> + <dt>{{domxref('GlobalEventHandlers.ondrop')}}</dt> + <dd>{{event('drop')}} 事件的{{domxref('GlobalEventHandlers','全局事件处理')}}。</dd> +</dl> + +<h2 id="示例">示例</h2> + +<p>每个属性,构造函数,事件类型和全局事件处理程序的示例都包含在它们各自的参考页中。</p> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName("HTML WHATWG", "interaction.html#the-dragevent-interface", "DragEvent")}}</td> + <td>{{Spec2("HTML WHATWG")}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("HTML5.1", "editing.html#the-dragevent-interface", "DragEvent")}}</td> + <td>{{Spec2("HTML5.1")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>Basic support</td> + <td>4</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("1.9.1")}}</td> + <td>10</td> + <td>12</td> + <td>3.1</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Android Webview</th> + <th>Chrome for Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>Firefox OS</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatIE("10")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<p><embed height="0" id="xunlei_com_thunder_helper_plugin_d462f475-c18e-46be-bd10-327458d045bd" type="application/thunder_download_plugin" width="0"></p> |