Created
December 12, 2017 15:34
-
-
Save npryce/2ba5e9bec206ea54f5b1908f12d07171 to your computer and use it in GitHub Desktop.
Kotlin definitions for browser touch API
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
package browser | |
import org.w3c.dom.Element | |
import org.w3c.dom.events.UIEvent | |
typealias TouchId = Int | |
external interface Touch { | |
val identifier: TouchId | |
val target: Element | |
val screenX: Double | |
val screenY: Double | |
val clientX: Double | |
val clientY: Double | |
val pageX: Double | |
val pageY: Double | |
} | |
external open class TouchList { | |
val length: Int | |
fun item(index: Int): Touch? | |
} | |
operator fun TouchList.get(n: Int) = | |
item(n) ?: throw IndexOutOfBoundsException("index out of bounds: $n, length: $length") | |
external open class TouchEvent : UIEvent { | |
val shiftKey: Boolean; | |
val ctrlKey: Boolean; | |
val altKey: Boolean; | |
val metaKey: Boolean; | |
/** | |
* See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. | |
*/ | |
fun getModifierState(key: String): Boolean; | |
val touches: TouchList; | |
val changedTouches: TouchList; | |
val targetTouches: TouchList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment