aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/globaleventhandlers/onmousedown/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/globaleventhandlers/onmousedown/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/api/globaleventhandlers/onmousedown/index.html')
-rw-r--r--files/ja/web/api/globaleventhandlers/onmousedown/index.html121
1 files changed, 121 insertions, 0 deletions
diff --git a/files/ja/web/api/globaleventhandlers/onmousedown/index.html b/files/ja/web/api/globaleventhandlers/onmousedown/index.html
new file mode 100644
index 0000000000..b983b353c0
--- /dev/null
+++ b/files/ja/web/api/globaleventhandlers/onmousedown/index.html
@@ -0,0 +1,121 @@
+---
+title: element.onmousedown
+slug: Web/API/globalEventhandlers/onmousedown
+tags:
+ - API
+ - Event Handler
+ - GlobalEventHandlers
+ - HTML DOM
+ - Property
+ - Reference
+translation_of: Web/API/GlobalEventHandlers/onmousedown
+---
+<div>{{ ApiRef("HTML DOM") }}</div>
+
+<p><strong><code>onmousedown</code></strong> は {{domxref("GlobalEventHandlers")}} ミックスインのプロパティで、{{event("mousedown")}} イベントを処理する{{domxref("EventHandler" ,"イベントハンドラー")}}です。</p>
+
+<p><code>mousedown</code> イベントは、ユーザーがマウスボタンを押したときに発生します。</p>
+
+<div class="blockIndicator note">
+<p><strong>メモ:</strong> <code>onmousedown</code> の反対の動作は {{domxref("GlobalEventHandlers.onmouseup", "onmouseup")}} です。</p>
+</div>
+
+<h2 id="構文">構文</h2>
+
+<pre class="syntaxbox notranslate"><em>target</em>.onmousedown = <em>functionRef</em>;
+</pre>
+
+<h3 id="値">値</h3>
+
+<p><code>functionRef</code> は、関数名または<a href="/docs/Web/JavaScript/Reference/Operators/function">関数式</a>です。この関数は、唯一の引数として {{domxref("MouseEvent")}} オブジェクトを受け取ります。</p>
+
+<h2 id="例">例</h2>
+
+<p>この例は、マウスボタンを押したままにすると画像の一部を表示します。<code>onmousedown</code>, {{domxref("GlobalEventHandlers.onmouseup", "onmouseup")}}, {{domxref("GlobalEventHandlers.onmousemove", "onmousemove")}} イベントハンドラーを使用します。</p>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush: html notranslate">&lt;div class="container"&gt;
+ &lt;div class="view" hidden&gt;&lt;/div&gt;
+ &lt;img src="https://interactive-examples.mdn.mozilla.net/media/examples/gecko-320-213.jpg"&gt;
+&lt;/div&gt;</pre>
+
+<h3 id="CSS">CSS</h3>
+
+<pre class="brush: css notranslate">.container {
+ width: 320px;
+ height: 213px;
+ background: black;
+}
+
+.view {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ background: white;
+ border-radius: 50%;
+}
+
+img {
+ mix-blend-mode: darken;
+}</pre>
+
+<h3 id="JavaScript">JavaScript</h3>
+
+<pre class="brush: js notranslate">function showView(event) {
+ view.removeAttribute('hidden');
+ view.style.left = event.clientX - 50 + 'px';
+ view.style.top = event.clientY - 50 + 'px';
+ event.preventDefault();
+}
+
+function moveView(event) {
+ view.style.left = event.clientX - 50 + 'px';
+ view.style.top = event.clientY - 50 + 'px';
+}
+
+function hideView(event) {
+ view.setAttribute('hidden', '');
+}
+
+const container = document.querySelector('.container');
+const view = document.querySelector('.view');
+
+container.onmousedown = showView;
+container.onmousemove = moveView;
+document.onmouseup = hideView;</pre>
+
+<h3 id="結果">結果</h3>
+
+<p>{{EmbedLiveSample("Example", 700, 300)}}</p>
+
+<h2 id="仕様">仕様</h2>
+
+<table class="spectable standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">仕様書</th>
+ <th scope="col">状態</th>
+ <th scope="col">備考</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML WHATWG','webappapis.html#handler-onmousedown','onmousedown')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="ブラウザの互換性">ブラウザの互換性</h2>
+
+<div>
+
+
+<p>{{Compat("api.GlobalEventHandlers.onmousedown")}}</p>
+</div>
+
+<h2 id="関連情報">関連情報</h2>
+
+<ul>
+ <li>{{event("mousedown")}} event</li>
+</ul>