diff --git a/touch-events/touch-event-tests.ts b/touch-events/touch-event-tests.ts new file mode 100644 index 0000000000..a1255813c2 --- /dev/null +++ b/touch-events/touch-event-tests.ts @@ -0,0 +1,33 @@ +/// + +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; diff --git a/touch-events/touch-events.d.ts b/touch-events/touch-events.d.ts new file mode 100644 index 0000000000..0810bd191d --- /dev/null +++ b/touch-events/touch-events.d.ts @@ -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; +}