Reputation: 1172
I'm trying to develop a menu where I can hover over the icons using my hand and then click on them using a pushing forward movement. To achieve that, I'm using the velocity my hand on the z-axis, plus the touch zone and the touch distance as you can see in this snippet of code.
var controller = new Leap.Controller({ enableGestures: flag });
controller.on('frame', function(frame) {
if (frame.pointables.length > 0) {
var pointable = frame.pointables[0];
// Params used to navigation and touching on menu interfaces
var touchZone = pointable.touchZone, // None, hovering, or touching
touchDistance = pointable.touchDistance, // [+1, 0, -1]
zNotFinger= pointable.tipVelocity[0], // For the case pointable isnn't a hand
zIndex = pointable.tipVelocity[1], // Index finger velocity on z-axis
zMiddle = pointable.tipVelocity[2], // Middle finger velocity on z-axis
x = pointable.tipPosition[0],
y = pointable.tipPosition[1],
// Getting highest tipVelocity
tempVelocity = zIndex >= zNotFinger ? zIndex : zNotFinger,
velocity = zMiddle > tempVelocity ? zMiddle : tempVelocity;
// The circle is defined as a gesture to go back to homepage
if (frame.hands.length === 1 && origin !== 'home' && frame.gestures.length > 0) {
var gesture = frame.gestures[0],
hand = frame.hands[0],
oneExtended = hand.fingers[1].extended && !hand.fingers[3].extended;
if (gesture.type === 'circle' && oneExtended && gesture.pointableIds.length >= 1) {
window.open('../html/home.html','_self');
}
}
// Sending data...
if (origin === 'home') {
homeHover(x, y, touchZone, touchDistance, velocity);
} else if (origin === 'bio') {
bioHover(x, y, touchZone, touchDistance, velocity);
} else if (origin === 'nature') {
natureHover(x, y, touchZone, touchDistance, velocity);
}
}
});
controller.connect();
}
and then...
if (velocity > 150) {
if ($(".hovered").attr("href") && touchZone === 'touching' && touchDistance <= -0.4) {
window.location.replace($(".hovered").attr("href"));
}
}
The main problem is to accidentally "click" on the links while hovering over the icons or set up the requires too high making difficult to click.
Could anyone give me a hand on that? Maybe new methods that I should use or even a completely different approach.
OBS: I already tried the screenTap and keyTap.
Many thanks!
Upvotes: 1
Views: 298
Reputation: 1388
The too hard or too easy to click is a common problem. The built-in taps have the same problem.
You could explore the stabilizedTipPosition instead of velocity (or in addition to velocity) and make the user move forward a predetermined amount after hovering. Using stabilizedTip position should make it easier for the user to push forward without accidentally moving off the target. Only clicking when the motion is primarily along the z axis should greatly reduce accidental clicks, both those that occur when the user is moving to a target menu item and those that occur when the user is just moving their hands (unrelated to the menu).
Other common approaches to menus include:
There are some menu design guidelines (older) here: https://developer.leapmotion.com/documentation/javascript/practices/Leap_Menu_Design_Guidelines.html
And several examples (not all menus, though): https://developer.leapmotion.com/gallery/category/javascript
Upvotes: 1