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/touchevent/targettouches | |
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/touchevent/targettouches')
-rw-r--r-- | files/zh-cn/web/api/touchevent/targettouches/index.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/touchevent/targettouches/index.html b/files/zh-cn/web/api/touchevent/targettouches/index.html new file mode 100644 index 0000000000..5b09634380 --- /dev/null +++ b/files/zh-cn/web/api/touchevent/targettouches/index.html @@ -0,0 +1,60 @@ +--- +title: TouchEvent.targetTouches +slug: Web/API/TouchEvent/targetTouches +translation_of: Web/API/TouchEvent/targetTouches +--- +<p id="Summary">{{ APIRef("Touch Events") }}</p> + +<p><strong><code>targetTouches</code></strong> 是一个只读的 {{ domxref("TouchList") }} 列表,包含仍与触摸面接触的所有触摸点的 {{ domxref("Touch") }} 对象。{{event("touchstart")}}事件触发在哪个{{ domxref("element") }}内,它就是当前目标元素。</p> + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre class="brush: js">var <em>touches</em> = <em>touchEvent</em>.targetTouches; +</pre> + +<h3 id="Return_Value" name="Return_Value">返回值</h3> + +<dl> + <dt><code>touches</code></dt> + <dd>一个 {{ domxref("TouchList") }},包含仍与触摸面接触的所有触摸点的 {{ domxref("Touch") }} 对象,{{event("touchstart")}}事件触发在哪个{{ domxref("element") }}内,它就是当前目标元素。</dd> +</dl> + +<h2 id="Specification" name="Specification">例子</h2> + +<p>本例阐述了 {{domxref("TouchEvent")}} 对象的 {{domxref("TouchEvent.targetTouches")}} 属性。{{domxref("TouchEvent.targetTouches")}} 属性也是一个 {{domxref("TouchList")}},其中包含的触摸点起始于触摸事件当前的目标元素,并且此刻正在触摸屏幕。所以,<font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">targetTouches</span></font> 元素是 <code>touches</code> 的真子集。</p> + +<p>下面代码段中的函数比较了 <code>touches</code> 列表和 <code>targetTouches</code> 列表的长度,返回值表示他们是否相等。</p> + +<pre class="brush: js">function touches_in_target(ev) { + // Return true if all of the touches are within the target element; + // otherwise return false. + return (ev.touches.length == ev.targetTouches.length ? true : false); +}</pre> + +<h2 id="Specification" name="Specification">规格</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('Touch Events 2','#widl-TouchEvent-targetTouches')}}</td> + <td>{{Spec2('Touch Events 2')}}</td> + <td>Non-stable version.</td> + </tr> + <tr> + <td>{{SpecName('Touch Events','#widl-TouchEvent-targetTouches')}}</td> + <td>{{Spec2('Touch Events')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + + + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{Compat("api.TouchEvent.targetTouches")}}</p> |