Coder Social home page Coder Social logo

mcanthony / khantrol-knob Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewkarasek/khantrol-knob

1.0 2.0 0.0 640 KB

UI control knob, jQuery plugin

Home Page: http://khantrol-knob.prythm.com

License: GNU General Public License v2.0

CSS 41.67% JavaScript 58.33%

khantrol-knob's Introduction

khantrol-knob

##Installation installing khantrol knob is really simple just include the required JS and CSS files in your document:

<script type="text/javascript" src="khantrol-knob.min.js"></script>
<link rel="stylesheet" href="khantrol-knob.css" />

##Basic Usage to use the knob with default settings first of all create an text input element:

<input type="text" id="khantrol-knob" />

then call the plugin in javascript:

$("#khantrol-knob").khantrolKnob();

to get the value use .val() on the original element:

$("#khantrol-knob").val()

###Tracking Changes to track any changes add an event listener to the original element:

$("#khantrol-knob").change(function(){
	console.log($(this).val());
});

events are also fired when the knob is turned to the minimun and maximum values, these can be tracked like so:

$("#khantrol-knob").on("max", function(){
	console.log("turned to max");
});
$("#khantrol-knob").on("min", function(){
	console.log("turned to min");
});

##Control Khantrol knob comes setup to work perfectly with the mouse and touch events, extra control can be added with the keyboard, when a holdKey or groupKey is definied the user can hold this key down and use the up and down keys on their keyboard to control the value of the knob. In this example the H key (keycode 72) is used as the holdKey:

$("#khantrolKnob").khantrolKnob({
	holdKey: 72
});

groupKey is made to be used across multiple knobs allowing you to control their values at the same time. In this example the G key is used as the groupKey:

$("#khantrolAlpha").khantrolKnob({
	groupKey: 71
});
$("#khantrolBravo").khantrolKnob({
	groupKey: 71
});
$("#khantrolCharlie").khantrolKnob({
	groupKey: 71
});

a full list of javascript keycodes can be found here.

##Styling khantrol knob comes with a default set of styles that work out of the box. If you want to custom style the knob you can simply give a value to css to create a custom class:

$("#khantrol-knob").khantrolKnob({
	css: "my-class";
})

this class will automatically be prefixed with "kk-" giving the class name .kk-my-class. To ensure the knob works correctly a width and height must be defined for .kk-face:

.kk-my-class .kk-face{
	width: 2em;
	height: 2em;
}

If you want a headstart some basic styles are supplied to ensure the knob functions as desired while allowing you to extend the styles, to access them use skeleton:

$("#khantrol-knob").khantrolKnob({
	css: "skeleton";
})

##Options

  • css (string) - allows a custom class to be passed to the wrapper with prefix ".kk-" for use with skins and custom styling default: "default"
  • responsive (bool) - used to create fluid with wrappers default: false
  • range (int) - range of degrees the knob will rotate default: 270
  • minVal (int) - minimum value the knob will give default: 0
  • maxVal (int) - maximum value the knob will give default: 100
  • speed (int) - speed at which the knob can be rotated default: 1
  • scale (int) - scale at which numbers increase and decrease (10, 1, 0.1 etc) default: 1
  • holdKey (int) - keycode to control the knob with, must be unique default: null
  • groupKey (int) - keycode to control the group, does not need to be unique default: null

#Examples

for examples please visit the Khantrol Knob Site

khantrol-knob's People

Stargazers

Michael Anthony avatar

Watchers

Michael Anthony avatar  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.