Skip to content

Commit 90c845a

Browse files
committed
Merge pull request #135 from mseddon/experimental-vibration-api
Add experimental Vibration API
2 parents 1efe494 + f3f2b03 commit 90c845a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.scalajs.dom.experimental
2+
3+
import scala.language.implicitConversions
4+
import scalajs.js
5+
6+
/**
7+
* Implicit imports for the vibration api.
8+
*
9+
* http://www.w3.org/TR/2015/REC-vibration-20150210/
10+
*/
11+
object Vibration {
12+
implicit def toVibration(n: org.scalajs.dom.Navigator): VibrationNavigator =
13+
n.asInstanceOf[VibrationNavigator]
14+
15+
class VibrationNavigator extends js.Any {
16+
/** Vibrate the device for the specified number of milliseconds. */
17+
def vibrate(duration: Double): Boolean = js.native
18+
19+
/**
20+
* Vibrate the device in the given pattern.
21+
*
22+
* @param pattern the pattern to vibrate. The first number is the initial
23+
* duration, the subsequent a delay of silence, and so on.
24+
*/
25+
def vibrate(pattern: js.Array[Double]): Boolean = js.native
26+
}
27+
}

0 commit comments

Comments
 (0)