Skip to content

Instantly share code, notes, and snippets.

@gorhgorh
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save gorhgorh/8916319 to your computer and use it in GitHub Desktop.

Select an option

Save gorhgorh/8916319 to your computer and use it in GitHub Desktop.
Modernizr test for leap motion
function checkLeap () {
// Hard dependency on websockets; quick exit if not supported
if (!Modernizr.websockets) {
Modernizr.addTest('leap', false);
}
// Try and connect to the leap daemon
var ws = new WebSocket("ws://localhost:6437/");
ws.onopen = function(event) {
Modernizr.addTest('leap', true);
};
ws.onerror = function(event) {
Modernizr.addTest('leap', false);
};
}
checkLeap();
@gorhgorh
Copy link
Author

thanks for the response !
i really love the Modernizr.addTest('leap', true); really handy, and clever work on the quick exit, i'll make a real github repo out if and post it to the twitter modernizr, so if someone else need it they could use it.

you confirmed my guesses on the async test, but in this case i could not boil it down to a "simpler" test.

on an other topic, is Modernizr.load deprecated ? i had to use yepnope directly to dynamically load my leap script

@stucox
Copy link

stucox commented Feb 11, 2014

Modernizr.load isn’t deprecated yet – but will be from v3.0.0. In v2.x you need to include it explicitly via the builder on http://modernizr.com/download though (in the “Extras” section on the right hand side).

@gorhgorh
Copy link
Author

ahh ok, i'm using the plain development version right now, planned on making a modular build later, i guess it is not included in it.

thanks for this wondefull tool by the way :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment