device-capabilities 0.0.4

Device Capabilities Library

Released 2016-02-01.

To install, run:

haxelib install device-capabilities 0.0.4

See using Haxelib in Haxelib documentation for more information.

Maintaineradireddy
Websitehttps://github.com/adireddy/device-capabilities
Current version0.0.4
StatisticsInstalled 8 times
LicenseMIT
Tags battery, device, device capabilities, devicemotion, geolocation, light, location, motion, orientation, sensor, vibrate, vibration

README.md

device-capabilities logo

Library to detect and use capabilities like Battery, DeviceMotion, Vibration, etc.

experimental

Build Status npm version

Installation

npm install device-capabilities.js

For haxe users:

haxelib install device-capabilities

API Documentation

Usage

<script src="dist/device-capabilities.min.js"></script>
var batterySupport = new BatterySupport(onReady);
var vibration = new Vibration();
var motion = new Motion();

function onReady() {
	console.log(batterySupport.isSupported);
	console.log("Charging: " + batterySupport.battery.charging);
	console.log("Charging Time: " + batterySupport.battery.chargingTime);
	console.log("Level: " + batterySupport.battery.level);
	console.log("Discharging Time: " + batterySupport.battery.dischargingTime);
}

motion.shake(onShake);
function onShake() {
	console.log("shake detected");
}

if (vibration.isSupported) {
    vibration.start(10000); // Vibrates for 10 seconds
    vibration.startPattern([200, 100, 300, 200, 50, 50, 50, 50, 1000]); // On and off vibration pattern
    vibration.stop(); // Stops vibration
}

Demo

Licensing Information

MIT license

This content is released under the MIT License.

Icon by Icons8

Contributor Code of Conduct

Code of Conduct is adapted from Contributor Covenant, version 1.3.0