下記のコードでデバイスがタッチイベントに対応しているかどうかで判定を行い
mouseとtouchのイベントの振り分けを実装していました。
ただタッチパネル対応PCの場合trueが返ってしまうようで、マウスでの操作が効かない状態になっていました。
var touchstart = 'mousedown', touchmove = 'mousemove', touchend = 'mouseup', var hasTapEvent = (function(){ var div = document.createElement('div'); div.setAttribute('ontouchstart', 'return'); return (typeof div.ontouchstart === 'function'); })(); if (hasTapEvent) { touchstart = 'touchstart'; touchmove = 'touchmove'; touchend = 'touchend'; }
タッチパネルに対応したPCでマウスとタッチを両対応させる事は可能でしょうか?
もしくはPCはタッチ対応でもマウス使用の場合はマウスを優先させる
(この時タッチは出来なくても良い)
といった方法でも構いません。
なにかスタンダードな実装方法があればご教授願います。
よろしくお願いします。
【マウス操作できない環境】
OS: windows7, 10
ブラウザ: GoogleChrome
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/07/07 04:29
2017/07/07 04:39
2017/07/07 09:11