[Edge]。→、、
mdn: 一定の間隔で発行され、その時点で端末が受けている加速度の物理的な力の量を示します。また、利用可能であれば、回転率に関する情報も提供します。
| バブリング | なし |
|---|---|
| キャンセル可能 | いいえ |
| インターフェイス | DeviceMotionEvent |
| イベント ハンドラー プロパティ | ondevicemotion |
HTML:
<SPAN id=IdLog></SPAN><BR> <SPAN id=IdInd></SPAN>
JavaScript:
function Job(eve){ //devicemotion イベントの処理:
D=eve; //=[object]:[object DeviceMotionEvent]。1回目に得たデータ。
詳細
//isTrusted=[boolean]:true
//acceleration=[object]:[object DeviceMotionEventAcceleration]
//accelerationIncludingGravity=[object]:[object DeviceMotionEventAcceleration]
//rotationRate=[object]:[object DeviceMotionEventRotationRate]
//interval=[number]:16
//type=[string]:devicemotion
//target=[object]:[object Window]
//currentTarget=[object]:[object Window]
//eventPhase=[number]:0
//bubbles=[boolean]:false
//cancelable=[boolean]:false
//defaultPrevented=[boolean]:false
//composed=[boolean]:false
//…
IdLog.innerHTML="X:"+eve.accelerationIncludingGravity.x+"<BR>"
+"Y:"+eve.accelerationIncludingGravity.y+"<BR>"
+"Z:"+eve.accelerationIncludingGravity.z;
IdInd.innerHTML=IdInd.innerHTML+"●";
}
window.ondevicemotion=Job; //イベント割り当て。
PCブラウザーでは画面がアクティブになる度にイベントが発生するようです。でもデータは null。