All Projects → ehzhang → Sense Js

ehzhang / Sense Js

Licence: mit
📱 html5 sensor interaction library for mobile

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Sense Js

Angular Web Bluetooth
The missing Web Bluetooth module for Angular
Stars: ✭ 164 (-25.11%)
Mutual labels:  sensor, html5
Jsqrscanner
JavaScript QR Code scanner for HTML5 supporting browsers
Stars: ✭ 212 (-3.2%)
Mutual labels:  html5
Jsonform
Build forms from JSON Schema. Easily template-able. Compatible with Bootstrap 3 out of the box.
Stars: ✭ 2,416 (+1003.2%)
Mutual labels:  html5
Design Blocks
A set of 170+ Bootstrap based design blocks ready to be used to create clean modern websites.
Stars: ✭ 13,317 (+5980.82%)
Mutual labels:  html5
Pristine
Vanilla javascript form validation micro-library
Stars: ✭ 197 (-10.05%)
Mutual labels:  html5
Streamsaver.js
StreamSaver writes stream to the filesystem directly asynchronous
Stars: ✭ 2,784 (+1171.23%)
Mutual labels:  html5
Onewirehub
OneWire slave device emulator
Stars: ✭ 195 (-10.96%)
Mutual labels:  sensor
Html Tips Tricks
My Favorite HTML5 Tips and Tricks
Stars: ✭ 217 (-0.91%)
Mutual labels:  html5
Recorder
html5 js 录音 mp3 wav ogg webm amr 格式,支持pc和Android、ios部分浏览器、和Hybrid App(提供Android IOS App源码),微信也是支持的,提供H5版语音通话聊天示例 和DTMF编解码
Stars: ✭ 2,891 (+1220.09%)
Mutual labels:  html5
Blockchain
A simple implementation of blockchain in java
Stars: ✭ 201 (-8.22%)
Mutual labels:  html5
Hardcandy Jekyll
一款清新 糖果色🍬 的 ‘Jekyll’ 主题。A candy-colored 🍬 ‘Jekyll’ theme.
Stars: ✭ 202 (-7.76%)
Mutual labels:  html5
Gravity View
Introducing Gravity View: Because swiping is so yesterday!
Stars: ✭ 200 (-8.68%)
Mutual labels:  sensor
Ionic Starter Template
Reinventing the wheel, again! Sorry Ionic Team... but there are many newbies learning on Youtube!
Stars: ✭ 208 (-5.02%)
Mutual labels:  html5
Stisla
Free Bootstrap Admin Template
Stars: ✭ 2,772 (+1165.75%)
Mutual labels:  html5
Viewscreen
Viewscreen - a personal video streaming server
Stars: ✭ 215 (-1.83%)
Mutual labels:  html5
Ovenplayer
OvenPlayer is Open-Source HTML5 Player. OvenPlayer supports WebRTC Signaling from OvenMediaEngine for Sub-Second Latency Streaming.
Stars: ✭ 196 (-10.5%)
Mutual labels:  html5
Chimee
a video player framework aims to bring wonderful experience on browser
Stars: ✭ 2,332 (+964.84%)
Mutual labels:  html5
One Html Page Challenge
Can you create something cool without modern tools?
Stars: ✭ 205 (-6.39%)
Mutual labels:  html5
Sheet Router
fast, modular client-side router
Stars: ✭ 219 (+0%)
Mutual labels:  html5
Cases
精选网页应用案例期刊
Stars: ✭ 217 (-0.91%)
Mutual labels:  html5

sense.js

an HTML5 interaction library for mobile browsers

Overview

HTML5 offers a lot of awesome access to hardware data. Sense.js is a library that abstracts away the math and gives developers and designers easy access to some common non-touch gesture interactions with simple javascript callbacks.

Disclaimer

This was made as a part of GreylockU's Hackfest, and will likely see changes to make things better/add more gestures :)

Pull requests and feature suggestions are welcome!

Demo

You can find a demo at http://sense-js.jit.su/

Orientation

A ball rolls around based on your screen position!

Flick

Flick your phone to the right or left to slide a color.

Flip

Flip your phone face down and face up, and a new color appears!

Color Fling

Open this page on multiple devices. Selecting a color and flicking it 'flicks' that color to all other devices.

Scroll

sense.js enabled scroll based on screen tilt

Quickstart

Download sense.js, and refer to it in an html file, and initialize it!

<script src="path/to/sense.js"></script>
<script>
    var sense = sense.init();
    
    sense.flick(function(data){
        // Your callback code here!
    });
</script>

Documentation

sense.orientation([options], callback)

Orientation fires continuously, and emits alpha, beta, and gamma data from the device.

Options Description Default
alphaThreshold (number) Threshold for changes in delta 0
betaThreshold (number) Threshold for changes in beta 0
gammaThreshold (number) Threshold for changes in gamma 0
radians (boolean) True to emit values in radians false
Data Description
alpha (number) degree/radian value for direction the device is pointed
beta (number) degree/radian value for device's front-back tilt
gamma (number) degree/radian value for device's left-right tilt

Sample Usage:

sense.orientation(function(data){
    console.log(data)
});

sense.flick([options], callback)

Flick events fire when the device is rotated quickly left-to-right or right-to-left.

Options Description Default
interval (number) the duration in milliseconds to watch for a flick event 150
sensitivity (number) multiplier to adjust amount of acceleration required. lower = more sensitive 1
Data Description
direction (String) 'left' or 'right' depending on the flick direction
magnitude (number) the magnitude of the acceleration on flick

Sample Usage:

sense.flick(function(data){
    slidePage(data.direction)
});

sense.fling([options], callback)

Fling events fire when the device is rotated quickly in the front-to-back direction, as if being thrown overhand (with the device facing towards you).

Options Description Default
interval (number) the duration in milliseconds to watch for a flick event 150
sensitivity (number) multiplier to adjust amount of acceleration required. lower = more sensitive 1
Data Description
magnitude (number) the magnitude of the acceleration on flick

Sample Usage:

sense.fling(function(data){
    sendFile();
});

sense.flip([options], callback)

Flip events fire when the phone is quickly flipped from face-up to face-down to face-up position.

Options Description Default
gestureDuration (number) timespan in milliseconds that the flip event can occur over 150
Data Description
gamma (number) the final gamma value after the flip

Sample Usage:

sense.flip(function(data){
    showRandomNumber();
});

sense.addTiltScroll([options])

This one line allows the user to observe the tilt of the user's phone to scroll on a page.

Options Description Default
maxHorizontalAngle (number) 80
maxHorizontalOffset (number) 100
maxHorizontalSpeed (number) 15
maxVerticalAngle (number) 40
maxVerticalOffset (number) 100
maxVerticalSpeed (number) 15

Sample Usage:

sense.addTiltScroll();

Debugging

We can initialize Sense with a debug flag!

var sense = sense.init({debug: true});

The debugger will include a fixed div in the bottom right corner that displays data when events fire. This is particularly useful when debugging on mobile, as you can't use debugger or console.log :(

To start the demo site:

$ npm install
$ npm start
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].