Skip to content

Commit 834f5c9

Browse files
prevent conflating pinch vs focus on terminal
1 parent 6a4342f commit 834f5c9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

com/isoterminal.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,15 @@ if( typeof AFRAME != 'undefined '){
387387
instance.addEventListener('window.onmaximize', resize )
388388

389389
const focus = (e) => {
390+
391+
// calculate distance between thumb and indexfinger to detect pinch
392+
// which should prevent focus-event (annoying to have keyboard popping up during pinch)
393+
if( e.detail?.withEl?.components['hand-tracking-controls'] ){
394+
const hand = e.detail.withEl.components['hand-tracking-controls']
395+
const thumb = hand.bones.find( (b) => b.name == 'thumb-tip' )
396+
const diff = thumb.position.distanceTo(hand.indexTipPosition)
397+
if( diff < 0.02) return // pinching! don't trigger keyboard (focus)
398+
}
390399
this.el.emit('focus',e.detail)
391400
}
392401

0 commit comments

Comments
 (0)