Add support for Touch API in JS Stdlib

#KT-34948 fixed
#KT-21445 fixed
This commit is contained in:
Alexey Trilis
2019-11-18 13:39:15 +03:00
parent 2dfa6c360b
commit 4f56b1a960
3 changed files with 70 additions and 0 deletions
+28
View File
@@ -3962,4 +3962,32 @@ CSSPseudoElement implements GeometryUtils;
Document implements GeometryUtils;
typedef (Text or Element or CSSPseudoElement or Document) GeometryNode;
// Downloaded from https://www.w3.org/TR/touch-events/
interface Touch {
readonly attribute long identifier;
readonly attribute EventTarget target;
readonly attribute long screenX;
readonly attribute long screenY;
readonly attribute long clientX;
readonly attribute long clientY;
readonly attribute long pageX;
readonly attribute long pageY;
};
interface TouchList {
readonly attribute unsigned long length;
getter Touch? item (unsigned long index);
};
interface TouchEvent : UIEvent {
readonly attribute TouchList touches;
readonly attribute TouchList targetTouches;
readonly attribute TouchList changedTouches;
readonly attribute boolean altKey;
readonly attribute boolean metaKey;
readonly attribute boolean ctrlKey;
readonly attribute boolean shiftKey;
};
partial interface Document {
Touch createTouch (WindowProxy view, EventTarget target, long identifier, long pageX, long pageY, long screenX, long screenY);
TouchList createTouchList (Touch... touches);
};
@@ -4938,6 +4938,8 @@ public external open class Document : Node, GlobalEventHandlers, DocumentAndElem
fun elementFromPoint(x: Double, y: Double): Element?
fun elementsFromPoint(x: Double, y: Double): Array<Element>
fun caretPositionFromPoint(x: Double, y: Double): CaretPosition?
fun createTouch(view: Window, target: EventTarget, identifier: Int, pageX: Int, pageY: Int, screenX: Int, screenY: Int): Touch
fun createTouchList(vararg touches: Touch): TouchList
fun exitFullscreen(): Promise<Unit>
override fun getElementById(elementId: String): Element?
override fun prepend(vararg nodes: dynamic)
@@ -5926,6 +5928,45 @@ public external interface GeometryUtils {
fun convertPointFromNode(point: DOMPointInit, from: dynamic, options: ConvertCoordinateOptions = definedExternally): DOMPoint
}
/**
* Exposes the JavaScript [Touch](https://developer.mozilla.org/en/docs/Web/API/Touch) to Kotlin
*/
public external abstract class Touch {
open val identifier: Int
open val target: EventTarget
open val screenX: Int
open val screenY: Int
open val clientX: Int
open val clientY: Int
open val pageX: Int
open val pageY: Int
open val region: String?
}
public external abstract class TouchList : ItemArrayLike<Touch> {
override fun item(index: Int): Touch?
}
@kotlin.internal.InlineOnly
public inline operator fun TouchList.get(index: Int): Touch? = asDynamic()[index]
public external open class TouchEvent : UIEvent {
open val touches: TouchList
open val targetTouches: TouchList
open val changedTouches: TouchList
open val altKey: Boolean
open val metaKey: Boolean
open val ctrlKey: Boolean
open val shiftKey: Boolean
companion object {
val NONE: Short
val CAPTURING_PHASE: Short
val AT_TARGET: Short
val BUBBLING_PHASE: Short
}
}
/**
* Exposes the JavaScript [Image](https://developer.mozilla.org/en/docs/Web/API/Image) to Kotlin
*/
@@ -101,6 +101,7 @@ private val urls = listOf(
"https://www.w3.org/TR/animation-timing/" to "org.w3c.dom",
"https://www.w3.org/TR/geometry-1/" to "org.w3c.dom",
"https://www.w3.org/TR/cssom-view/" to "org.w3c.dom",
"https://www.w3.org/TR/touch-events/" to "org.w3c.dom",
"https://www.w3.org/TR/uievents/" to "org.w3c.dom.events",
"https://www.w3.org/TR/pointerevents/" to "org.w3c.dom.pointerevents",