uxer flat dial
flat dial is a flat UI component that gives you a spin event for whatever element you cast it on. It works for touch and regular mouse drag. You just cast this function on an element, and then element.addEventListener('spin', spinFunc);
Your function will get an event object with some parameters, like vector, delta, and degreeChange. You can use those as ingredients in ur css to make the dial spin, as in the example below. An use it to create spin/swirl interactions.
Flat Dial uses the spin module from a proto library of UI components called uxer which uses the event module touchdown at its core.
To use, install and require it.
npm install uxer-flat-dial
var dial = ;var myDialElement = ; // returns an HTMLElement
See the example below, which can be easily run if you have browserify and opa installed:
npm install -g browserify opa
git clone https://github.com/NHQ/uxer-flat-dial.git
cd uxer-flat-dial
opa -e examples/example.js -n
Options
pass an options object to the function (see below); options are:
height
width
color
bgcolor
Example - from examples/example.js
var spin = ;var Flatdial = ; { var opts = {}; optswidth = w; // set width or height and the other will be set automatically for roundness optscolor = c; optsbgcolor = bg; var flatdial = ; // create a parent div to position our dial on the page var div = document; divstyleposition = 'absolute'; divstyle'margin-left' = left + 'px'; divstyle'margin-top' = top + 'px'; div; documentbody documentbody ; var spinDegree = 90; flatdialnode;}