Giter VIP home page Giter VIP logo

knobs's Introduction

Knob.js

Javascript Library for Multitouch Virtual Knobs

Knob.js makes it easy to include multitouch virtual knobs in your web app.

Knob.js does the heavy lifting for things like:

  • Minimum/maximum angle & value constraints.
  • Figuring out the position and angle of the indicator dot.
  • Doing the math for displaying custom rendered knobs using image sprites.

Knob.js is a purely logical component - rather than drawing or moving things around, it only crunches the numbers and gives back positions and angles. This means that you can render your virtual knobs using CSS, <canvas>, <svg>, or however you like.


Gesture support

Knob.js recognizes spinning and sliding gestures. Spin the knob and it follows your finger. Start sliding up/down or left/right and it locks into the direction and acts like a slider. Mouse interaction including scrolling is also supported.


Demos

Indicator Showcase: CSS | canvas | SVG

More demos coming soon


Usage

Download the minified library and include it in your html.

	<script src="js/Knob.js"></script>

This code creates a knob that goes from zero to eleven, starting at 220 degrees and going to -40 degrees (that's 8 o'clock to 4 o'clock for people that like thinking in clockfaces).

	<script>

	var knob = new Knob(function(knob, angle, val, indicator, spriteOffset) {
		// apply knob/indicator position/angle to UI
	}, {
		angleStart: 220, // (~8 o'clock)
		angleEnd: -40,   // (~4 o'clock)
		valueMin: 0,
		valueMax: 11 // this one goes to eleven
	});

	</script>

Acknowledgements

Knob.js wouldn't be here without Apple's Garageband for iOS. The designers/developers really put a lot of thought into the way a virtual knob should work. Thanks.

The layout of the javascript was heavily influenced by Zynga's Scroller.

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.