mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
Fix several tests
This commit is contained in:
@@ -3,12 +3,16 @@ DefinitelyTyped [
|
||||
|
||||
Contributor Guidelines
|
||||
----------------------
|
||||
|
||||
@@ -16,11 +20,8 @@ See the section: [How to contribute](https://github.com/borisyankov/DefinitelyTy
|
||||
|
||||
Other means to get the definitions
|
||||
----------------------------------
|
||||
|
||||
* [NuGet packages](http://nuget.org/packages?q=Definitelytyped)
|
||||
|
||||
* [TypeScript definition package manager](https://github.com/Diullei/tsd)
|
||||
|
||||
* [tsdpm](http://www.tsdpm.com/) - Online search
|
||||
|
||||
List of Definitions
|
||||
|
||||
@@ -244,7 +244,6 @@ function test_bindings() {
|
||||
};
|
||||
|
||||
var node, containerElem, nodeToInsert, insertAfter, nodeToPrepend, arrayOfNodes;
|
||||
ko.virtualElements.allowedBindings.mySuperBinding = true;
|
||||
ko.virtualElements.emptyNode(containerElem);
|
||||
ko.virtualElements.firstChild(containerElem);
|
||||
ko.virtualElements.insertAfter(containerElem, nodeToInsert, insertAfter);
|
||||
|
||||
@@ -1,89 +1,84 @@
|
||||
import Leap = module('../LeapMotionTS');
|
||||
var controller:Leap.Controller = new Leap.Controller();
|
||||
controller.addEventListener( Leap.LeapEvent.LEAPMOTION_FRAME, ( event:Leap.LeapEvent ) => {
|
||||
var frame:Leap.Frame = event.frame;
|
||||
console.log( "Frame id: " + frame.id + ", timestamp: " + frame.timestamp + ", hands: " + frame.hands.length + ", fingers: " + frame.fingers.length + ", tools: " + frame.tools.length + ", gestures: " + frame.gestures().length );
|
||||
/// <reference path="LeapMotionTS.d.ts" />
|
||||
|
||||
if ( frame.hands.length > 0 )
|
||||
{
|
||||
import Leap = module('../LeapMotionTS');
|
||||
|
||||
var controller: Leap.Controller = new Leap.Controller();
|
||||
controller.addEventListener(Leap.LeapEvent.LEAPMOTION_FRAME, (event: Leap.LeapEvent) => {
|
||||
var frame: Leap.Frame = event.frame;
|
||||
console.log("Frame id: " + frame.id + ", timestamp: " + frame.timestamp + ", hands: " + frame.hands.length + ", fingers: " + frame.fingers.length + ", tools: " + frame.tools.length + ", gestures: " + frame.gestures().length);
|
||||
|
||||
if (frame.hands.length > 0) {
|
||||
// Get the first hand
|
||||
var hand:Leap.Hand = frame.hands[ 0 ];
|
||||
var hand: Leap.Hand = frame.hands[0];
|
||||
|
||||
// Check if the hand has any fingers
|
||||
var fingers:Leap.Finger[] = hand.fingers;
|
||||
if ( fingers.length > 0 )
|
||||
{
|
||||
var fingers: Leap.Finger[] = hand.fingers;
|
||||
if (fingers.length > 0) {
|
||||
// Calculate the hand's average finger tip position
|
||||
var avgPos:Leap.Vector3 = Leap.Vector3.zero();
|
||||
for(var i:number = 0; i < fingers.length; i++ )
|
||||
avgPos = avgPos.plus( (<Leap.Finger>fingers[ i ]).tipPosition );
|
||||
var avgPos: Leap.Vector3 = Leap.Vector3.zero();
|
||||
for (var i: number = 0; i < fingers.length; i++)
|
||||
avgPos = avgPos.plus((<Leap.Finger>fingers[i]).tipPosition);
|
||||
|
||||
avgPos = avgPos.divide( fingers.length );
|
||||
console.log( "Hand has " + fingers.length + " fingers, average finger tip position: " + avgPos );
|
||||
avgPos = avgPos.divide(fingers.length);
|
||||
console.log("Hand has " + fingers.length + " fingers, average finger tip position: " + avgPos);
|
||||
}
|
||||
|
||||
// Get the hand's sphere radius and palm position
|
||||
console.log( "Hand sphere radius: " + hand.sphereRadius + " mm, palm position: " + hand.palmPosition );
|
||||
console.log("Hand sphere radius: " + hand.sphereRadius + " mm, palm position: " + hand.palmPosition);
|
||||
|
||||
// Get the hand's normal vector and direction
|
||||
var normal:Leap.Vector3 = hand.palmNormal;
|
||||
var direction:Leap.Vector3 = hand.direction;
|
||||
var normal: Leap.Vector3 = hand.palmNormal;
|
||||
var direction: Leap.Vector3 = hand.direction;
|
||||
|
||||
// Calculate the hand's pitch, roll, and yaw angles
|
||||
console.log( "Hand pitch: " + Leap.LeapUtil.toDegrees( direction.pitch ) + " degrees, " + "roll: " + Leap.LeapUtil.toDegrees( normal.roll ) + " degrees, " + "yaw: " + Leap.LeapUtil.toDegrees( direction.yaw ) + " degrees\n" );
|
||||
console.log("Hand pitch: " + Leap.LeapUtil.toDegrees(direction.pitch) + " degrees, " + "roll: " + Leap.LeapUtil.toDegrees(normal.roll) + " degrees, " + "yaw: " + Leap.LeapUtil.toDegrees(direction.yaw) + " degrees\n");
|
||||
}
|
||||
|
||||
var gestures:Leap.Gesture[] = frame.gestures();
|
||||
for ( var i:number = 0; i < gestures.length; i++ )
|
||||
{
|
||||
var gesture:Leap.Gesture = gestures[ i ];
|
||||
var gestures: Leap.Gesture[] = frame.gestures();
|
||||
for (var i: number = 0; i < gestures.length; i++) {
|
||||
var gesture: Leap.Gesture = gestures[i];
|
||||
|
||||
switch ( gesture.type )
|
||||
{
|
||||
switch (gesture.type) {
|
||||
case Leap.Gesture.TYPE_CIRCLE:
|
||||
var circle:Leap.CircleGesture = <Leap.CircleGesture>gesture;
|
||||
var circle: Leap.CircleGesture = <Leap.CircleGesture>gesture;
|
||||
|
||||
// Calculate clock direction using the angle between circle normal and pointable
|
||||
var clockwiseness:String;
|
||||
if ( circle.pointable.direction.angleTo( circle.normal ) <= Math.PI / 4 )
|
||||
{
|
||||
var clockwiseness: String;
|
||||
if (circle.pointable.direction.angleTo(circle.normal) <= Math.PI / 4) {
|
||||
// Clockwise if angle is less than 90 degrees
|
||||
clockwiseness = "clockwise";
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
clockwiseness = "counterclockwise";
|
||||
}
|
||||
|
||||
// Calculate angle swept since last frame
|
||||
var sweptAngle:number = 0;
|
||||
if ( circle.state != Leap.Gesture.STATE_START )
|
||||
{
|
||||
var previousGesture:Leap.Gesture = controller.frame( 1 ).gesture( circle.id );
|
||||
if( previousGesture.isValid() )
|
||||
{
|
||||
var previousUpdate:Leap.CircleGesture = (<Leap.CircleGesture>controller.frame( 1 ).gesture( circle.id ) );
|
||||
sweptAngle = ( circle.progress - previousUpdate.progress ) * 2 * Math.PI;
|
||||
var sweptAngle: number = 0;
|
||||
if (circle.state != Leap.Gesture.STATE_START) {
|
||||
var previousGesture: Leap.Gesture = controller.frame(1).gesture(circle.id);
|
||||
if (previousGesture.isValid()) {
|
||||
var previousUpdate: Leap.CircleGesture = (<Leap.CircleGesture>controller.frame(1).gesture(circle.id));
|
||||
sweptAngle = (circle.progress - previousUpdate.progress) * 2 * Math.PI;
|
||||
}
|
||||
}
|
||||
|
||||
console.log( "Circle id: " + circle.id + ", " + circle.state + ", progress: " + circle.progress + ", radius: " + circle.radius + ", angle: " + Leap.LeapUtil.toDegrees( sweptAngle ) + ", " + clockwiseness );
|
||||
console.log("Circle id: " + circle.id + ", " + circle.state + ", progress: " + circle.progress + ", radius: " + circle.radius + ", angle: " + Leap.LeapUtil.toDegrees(sweptAngle) + ", " + clockwiseness);
|
||||
break;
|
||||
case Leap.Gesture.TYPE_SWIPE:
|
||||
var swipe:Leap.SwipeGesture = <Leap.SwipeGesture>gesture;
|
||||
console.log( "Swipe id: " + swipe.id + ", " + swipe.state + ", position: " + swipe.position + ", direction: " + swipe.direction + ", speed: " + swipe.speed );
|
||||
var swipe: Leap.SwipeGesture = <Leap.SwipeGesture>gesture;
|
||||
console.log("Swipe id: " + swipe.id + ", " + swipe.state + ", position: " + swipe.position + ", direction: " + swipe.direction + ", speed: " + swipe.speed);
|
||||
break;
|
||||
case Leap.Gesture.TYPE_SCREEN_TAP:
|
||||
var screenTap:Leap.ScreenTapGesture = <Leap.ScreenTapGesture>gesture;
|
||||
console.log( "Screen Tap id: " + screenTap.id + ", " + screenTap.state + ", position: " + screenTap.position + ", direction: " + screenTap.direction );
|
||||
var screenTap: Leap.ScreenTapGesture = <Leap.ScreenTapGesture>gesture;
|
||||
console.log("Screen Tap id: " + screenTap.id + ", " + screenTap.state + ", position: " + screenTap.position + ", direction: " + screenTap.direction);
|
||||
break;
|
||||
case Leap.Gesture.TYPE_KEY_TAP:
|
||||
var keyTap:Leap.KeyTapGesture = <Leap.KeyTapGesture>gesture;
|
||||
console.log( "Key Tap id: " + keyTap.id + ", " + keyTap.state + ", position: " + keyTap.position + ", direction: " + keyTap.direction );
|
||||
var keyTap: Leap.KeyTapGesture = <Leap.KeyTapGesture>gesture;
|
||||
console.log("Key Tap id: " + keyTap.id + ", " + keyTap.state + ", position: " + keyTap.position + ", direction: " + keyTap.direction);
|
||||
break;
|
||||
default:
|
||||
console.log( "Unknown gesture type." );
|
||||
console.log("Unknown gesture type.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
Vendored
+20
-1
@@ -2,6 +2,8 @@
|
||||
// Project: https://github.com/logotype/LeapMotionTS and http://www.leapmotion.com
|
||||
// Definitions by: Victor Norgren <https://github.com/logotype/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
export declare class EventDispatcher {
|
||||
private _listeners;
|
||||
constructor();
|
||||
@@ -10,6 +12,7 @@ export declare class EventDispatcher {
|
||||
public removeEventListener(typeStr: string, listenerFunc: Function): void;
|
||||
public dispatchEvent(evt: LeapEvent): void;
|
||||
}
|
||||
|
||||
export interface Listener {
|
||||
onConnect(controller: Controller): void;
|
||||
onDisconnect(controller: Controller): void;
|
||||
@@ -17,6 +20,7 @@ export interface Listener {
|
||||
onFrame(controller: Controller, frame: Frame): void;
|
||||
onInit(controller: Controller): void;
|
||||
}
|
||||
|
||||
export declare class DefaultListener extends EventDispatcher implements Listener {
|
||||
constructor();
|
||||
public onConnect(controller: Controller): void;
|
||||
@@ -25,6 +29,7 @@ export declare class DefaultListener extends EventDispatcher implements Listener
|
||||
public onFrame(controller: Controller, frame: Frame): void;
|
||||
public onInit(controller: Controller): void;
|
||||
}
|
||||
|
||||
export declare class LeapEvent {
|
||||
static LEAPMOTION_INIT: string;
|
||||
static LEAPMOTION_CONNECTED: string;
|
||||
@@ -38,6 +43,7 @@ export declare class LeapEvent {
|
||||
public getTarget(): any;
|
||||
public getType(): string;
|
||||
}
|
||||
|
||||
export declare class LeapUtil {
|
||||
static PI: number;
|
||||
static DEG_TO_RAD: number;
|
||||
@@ -67,6 +73,7 @@ export declare class LeapUtil {
|
||||
static lerp(a: number, b: number, coefficient: number): number;
|
||||
static lerpVector(vec1: Vector3, vec2: Vector3, coefficient: number): Vector3;
|
||||
}
|
||||
|
||||
export declare class Controller extends EventDispatcher {
|
||||
private listener;
|
||||
public frameHistory: Frame[];
|
||||
@@ -83,6 +90,7 @@ export declare class Controller extends EventDispatcher {
|
||||
public isGestureEnabled(type: number): boolean;
|
||||
public isConnected(): boolean;
|
||||
}
|
||||
|
||||
export declare class Pointable {
|
||||
public direction: Vector3;
|
||||
public frame: Frame;
|
||||
@@ -100,6 +108,7 @@ export declare class Pointable {
|
||||
static invalid(): Pointable;
|
||||
public toString(): string;
|
||||
}
|
||||
|
||||
export declare class Gesture {
|
||||
static STATE_INVALID: number;
|
||||
static STATE_START: number;
|
||||
@@ -124,14 +133,17 @@ export declare class Gesture {
|
||||
static invalid(): Gesture;
|
||||
public toString(): string;
|
||||
}
|
||||
|
||||
export declare class Finger extends Pointable {
|
||||
constructor();
|
||||
static invalid(): Finger;
|
||||
}
|
||||
|
||||
export declare class Tool extends Pointable {
|
||||
constructor();
|
||||
static invalid(): Tool;
|
||||
}
|
||||
|
||||
export declare class Hand {
|
||||
public direction: Vector3;
|
||||
public fingers: Finger[];
|
||||
@@ -160,6 +172,7 @@ export declare class Hand {
|
||||
public translation(sinceFrame: Frame): Vector3;
|
||||
static invalid(): Hand;
|
||||
}
|
||||
|
||||
export declare class Frame {
|
||||
public fingers: Finger[];
|
||||
public hands: Hand[];
|
||||
@@ -188,6 +201,7 @@ export declare class Frame {
|
||||
public isValid(): boolean;
|
||||
static invalid(): Frame;
|
||||
}
|
||||
|
||||
export declare class Matrix {
|
||||
public origin: Vector3;
|
||||
public xBasis: Vector3;
|
||||
@@ -204,6 +218,7 @@ export declare class Matrix {
|
||||
static identity(): Matrix;
|
||||
public toString(): string;
|
||||
}
|
||||
|
||||
export declare class CircleGesture extends Gesture {
|
||||
static classType: number;
|
||||
public center: Vector3;
|
||||
@@ -213,6 +228,7 @@ export declare class CircleGesture extends Gesture {
|
||||
public radius: number;
|
||||
constructor();
|
||||
}
|
||||
|
||||
export declare class KeyTapGesture extends Gesture {
|
||||
static classType: number;
|
||||
public direction: Vector3;
|
||||
@@ -221,6 +237,7 @@ export declare class KeyTapGesture extends Gesture {
|
||||
public progress: number;
|
||||
constructor();
|
||||
}
|
||||
|
||||
export declare class ScreenTapGesture extends Gesture {
|
||||
static classType: number;
|
||||
public direction: Vector3;
|
||||
@@ -229,6 +246,7 @@ export declare class ScreenTapGesture extends Gesture {
|
||||
public progress: number;
|
||||
constructor();
|
||||
}
|
||||
|
||||
export declare class SwipeGesture extends Gesture {
|
||||
static classType: number;
|
||||
public direction: Vector3;
|
||||
@@ -238,6 +256,7 @@ export declare class SwipeGesture extends Gesture {
|
||||
public startPosition: Vector3;
|
||||
constructor();
|
||||
}
|
||||
|
||||
export declare class Vector3 {
|
||||
public x: number;
|
||||
public y: number;
|
||||
@@ -276,4 +295,4 @@ export declare class Vector3 {
|
||||
static forward(): Vector3;
|
||||
static backward(): Vector3;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
@@ -62,13 +62,6 @@ interface SignalR {
|
||||
|
||||
function test_hubs() {
|
||||
var chat = $.connection.chat;
|
||||
chat.client.addMessage = function (message) {
|
||||
$('#messages').append('<li>' + message + '</li>');
|
||||
};
|
||||
|
||||
$("#broadcast").click(function () {
|
||||
chat.server.send($('#msg').val());
|
||||
});
|
||||
$.connection.hub.start()
|
||||
.done(function () { alert("Now connected!"); })
|
||||
.fail(function () { alert("Could not Connect!"); });
|
||||
|
||||
@@ -68,7 +68,6 @@ _V_("example_video_1").ready(function(){
|
||||
var myPlayer: VideoJSPlayer = this;
|
||||
// Do something when the event is fired
|
||||
};
|
||||
myPlayer.addEvent("volumechange", myFunc);
|
||||
myPlayer.removeEvent("volumechange", myFunc);
|
||||
|
||||
//myPlayer.addEvent("volumechange", myFunc);
|
||||
//myPlayer.removeEvent("volumechange", myFunc);
|
||||
});
|
||||
Reference in New Issue
Block a user