|  | 
| 1 | 1 | package org.scalajs.dom.ext | 
| 2 | 2 | 
 | 
| 3 |  | -import org.scalajs.dom.html | 
|  | 3 | +import scala.language.implicitConversions | 
|  | 4 | +import scala.concurrent.{Promise, Future} | 
| 4 | 5 | 
 | 
| 5 | 6 | import scala.scalajs.js | 
|  | 7 | + | 
| 6 | 8 | import org.scalajs.dom | 
|  | 9 | +import org.scalajs.dom.{html, raw} | 
| 7 | 10 | 
 | 
| 8 | 11 | /** | 
| 9 | 12 |  * Used to extend out javascript *Collections to make them usable as normal | 
| @@ -151,7 +154,7 @@ object KeyCode { | 
| 151 | 154 |  val z = 90 | 
| 152 | 155 | } | 
| 153 | 156 | 
 | 
| 154 |  | -import scala.concurrent.{Promise, Future} | 
|  | 157 | + | 
| 155 | 158 | /** | 
| 156 | 159 |  * Thrown when `Ajax.get` or `Ajax.post` receives a non-20X response code. | 
| 157 | 160 |  * Contains the XMLHttpRequest that resulted in that response | 
| @@ -245,3 +248,58 @@ sealed class Storage(domStorage: dom.Storage) { | 
| 245 | 248 | object SessionStorage extends Storage(dom.sessionStorage) | 
| 246 | 249 | 
 | 
| 247 | 250 | object LocalStorage extends Storage(dom.localStorage) | 
|  | 251 | + | 
|  | 252 | +/** | 
|  | 253 | + * W3C recommendation for touch events | 
|  | 254 | + * | 
|  | 255 | + * @see http://www.w3.org/TR/touch-events/ | 
|  | 256 | + */ | 
|  | 257 | +trait TouchEvents extends js.Object { | 
|  | 258 | + /** | 
|  | 259 | + * The touchstart event is fired when a touch point is placed on the touch | 
|  | 260 | + * surface. | 
|  | 261 | + * | 
|  | 262 | + * MDN | 
|  | 263 | + */ | 
|  | 264 | + var ontouchstart: js.Function1[raw.TouchEvent, _] = js.native | 
|  | 265 | + | 
|  | 266 | + /** | 
|  | 267 | + * The touchmove event is fired when a touch point is moved along the touch | 
|  | 268 | + * surface. | 
|  | 269 | + * | 
|  | 270 | + * MDN | 
|  | 271 | + */ | 
|  | 272 | + var ontouchmove: js.Function1[raw.TouchEvent, _] = js.native | 
|  | 273 | + | 
|  | 274 | + /** | 
|  | 275 | + * The touchend event is fired when a touch point is removed from the touch | 
|  | 276 | + * surface. | 
|  | 277 | + * | 
|  | 278 | + * MDN | 
|  | 279 | + */ | 
|  | 280 | + var ontouchend: js.Function1[raw.TouchEvent, _] = js.native | 
|  | 281 | + | 
|  | 282 | + /** | 
|  | 283 | + * The touchcancel event is fired when a touch point has been disrupted in an | 
|  | 284 | + * implementation-specific manner (too many touch points for example). | 
|  | 285 | + * | 
|  | 286 | + * MDN | 
|  | 287 | + */ | 
|  | 288 | + var ontouchcancel: js.Function1[raw.TouchEvent, _] = js.native | 
|  | 289 | +} | 
|  | 290 | + | 
|  | 291 | +/** | 
|  | 292 | + * Implicits to add touch event handlers to [[raw.HTMLDocument]] and | 
|  | 293 | + * [[raw.Window]]. | 
|  | 294 | + * | 
|  | 295 | + * @note Touch events may not be available on all modern browsers. See | 
|  | 296 | + * http://www.quirksmode.org/mobile/tableTouch.html#t00 for a compatibility | 
|  | 297 | + * table. | 
|  | 298 | + */ | 
|  | 299 | +object TouchEvents { | 
|  | 300 | + implicit def HTMLDocumentToTouchEvents(html: raw.HTMLDocument): TouchEvents = | 
|  | 301 | + html.asInstanceOf[TouchEvents] | 
|  | 302 | + | 
|  | 303 | + implicit def WindowToTouchEvents(window: raw.Window): TouchEvents = | 
|  | 304 | + window.asInstanceOf[TouchEvents] | 
|  | 305 | +} | 
0 commit comments