add interface for HTML Touch events

This commit is contained in:
Kevin Barabash
2014-11-28 18:48:58 -07:00
parent 974747ee99
commit 4e705d89a9
2 changed files with 63 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
/// <reference path="touch-events.d.ts"/>
var touchEvent:TouchEvent;
var list:TouchList;
var touch:Touch;
list = touchEvent.touches;
list = touchEvent.targetTouches;
list = touchEvent.changedTouches;
var flag:boolean;
flag = touchEvent.altKey;
flag = touchEvent.metaKey;
flag = touchEvent.ctrlKey;
flag = touchEvent.shiftKey;
var len:number = list.length;
touch = list.item(0);
var x: number;
var y: number;
var id: number;
id = touch.identifier;
x = touch.screenX;
y = touch.screenY;
x = touch.clientX;
y = touch.clientY;
x = touch.pageX;
y = touch.pageY;
var target:EventTarget;
target = touch.target;
+30
View File
@@ -0,0 +1,30 @@
// Type definitions for HTML Touch Events
// Project: http://www.w3.org/TR/touch-events/
// Definitions by: Kevin Barabash https://github.com/kevinb7
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface TouchEvent extends UIEvent {
touches: TouchList;
targetTouches: TouchList;
changedTouches: TouchList;
altKey: boolean;
metaKey: boolean;
ctrlKey: boolean;
shiftKey: boolean;
}
interface TouchList {
length: number;
item: (index: number) => Touch;
}
interface Touch {
identifier: number;
target: EventTarget;
screenX: number;
screenY: number;
clientX: number;
clientY: number;
pageX: number;
pageY: number;
}