Last active
August 29, 2015 13:56
-
-
Save gorhgorh/8916319 to your computer and use it in GitHub Desktop.
Modernizr test for leap motion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
Author
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).
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
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