Giter Club home page Giter Club logo

jogdial.js's Introduction

JogDial.js

A JavaScript plugin for jog dial controls.

JogDial is a simple JavaScript plugin that help you to create dial style controller easily on the webpage.

Supported browsers and device

JogDial supports Chrome, Safari, FireFox, Internet Explorer 7+ and most of modern browsers include mobile device.

Features

  • Does not require any other JavaScript library like jQuery.
  • Cross-browser support (IE7+)
  • Multi-touch support (you can control multiple number of JogDial elements at once in touch screen)
  • DOM Events
  • AMD Support (RequreJS)

Demo

Click here

Usage

Basics

Here is a basic example of JogDial.js initialization. This will start the JogDial in debug mode.

You must create the target element for the JogDial and setup the width and height property before the code start.

var el = document.getElementById('your_element');
var dial = JogDial(el, {debug: true});

You can change the setting by passing an options (array) in second argument.

var options = {debug: true, wheelSize: 90%, knobSize: 50%, minDegree: 0};
var dial = JogDial(el, options);

Styling

The easiest way to style the JogDial is adding background image to your target element and knob element created from JogDial script.

JodDial always return the knob id name append to the target element name you've created.

For an example, if you named the tag element id as "dial", then knob id will be "dial_knob".

#dial {
    width: 200px;
    height: 200px;
}

#dial_knob {
    // This is your knob style
}

You can add any additional elements inside of your target element and it won't interfere the JogDial function.

Options

Here is a list of options can be used on JogDial.

Options Descriptions Default
debug bool Show debug overlay on the top of screen false
touchMode string Set the active touch area of JogDial control. 'knob' or 'wheel' knob
knobSize int Set the diameter of knob in percentage or pixel 30%
wheelSize int Set the diameter of wheel in percentage or pixel 100%
zIndex int Set the z-index of JogDial 9999
degreeStartAt int Set the degree of wheel at start 0
minDegree int Set the minimum degree of wheel rotation null (infinite)
maxDegree int Set the maximum degree of wheel rotation null (infinite)

Events

Events can be added or removed with the on and off methods and those are chainable like a jQuery.

JogDial(el, {debug: true})
.on("mousemove", function(event){ console.log(event.target.rotation); })
.on("mouseup", function(event){ console.log(event.target.rotation); });

Event list

  • mousedown
  • mousemove
  • mouseup

Event Data list from callback

event.target.rotation  {number}     total sum of rotated degree from the start.
event.target.degree    {number}     Current degree of circle in clock angle.

Triggering

You can change the angle of JogDial element by passing the number value to 'angle' function.

var dial = JogDial(el, {debug: true});
dial.angle(45); 
// This will change the JogDial degree to 45.

Copyright

Licensed under the MIT license

jogdial.js's People

Contributors

ohsiwon avatar will-swu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.