Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #30 from eskimoblood/bugfix

adding a way to set the 0 position of the knob, fixing issue #26
  • Loading branch information...
commit e470432598bca78cc816439e77a54e513f46a6e4 2 parents b83cec8 + b60a6f2
@aterrien authored
Showing with 10 additions and 3 deletions.
  1. +1 −0  README.md
  2. +2 −1  index.html
  3. +7 −2 js/jquery.knob.js
View
1  README.md
@@ -37,6 +37,7 @@ Behaviors :
* max : max value || default=100.
* stopper : stop at 0 & 100 on keydown/mousewheel || default=true.
* readOnly : disable input and events.
+* angleOffset: change the 0 position of the knob (in degree), || default=0.
UI :
* cursor : display mode "cursor" | default=gauge.
View
3  index.html
@@ -126,8 +126,9 @@
data-min="-100"
data-cgColor="#A9EFFD"
data-displayPrevious=true
+data-angleOffset="90"
</pre>
- <input class="knob"data-width="200" data-min="-100" data-displayPrevious=true value="44">
+ <input class="knob"data-width="200" data-min="-100" data-angleOffset="90" data-displayPrevious=true value="44">
</div>
<div style="clear:both"></div>
<div style="float:left;width:300px;height:320px;padding:20px">
View
9 js/jquery.knob.js
@@ -19,7 +19,7 @@ $(function () {
var v = null
,ctx = c[0].getContext("2d")
- ,PI2 = 2*Math.PI
+ ,PI2 = 2 * Math.PI
,mx ,my ,x ,y
,self = this;
@@ -55,7 +55,7 @@ $(function () {
this.draw = function (nv) {
var a = this.angle(nv) // Angle
- ,sa = 1.5 * Math.PI // Previous start angle
+ ,sa = 1.5 * Math.PI + opt.angleOffset // Previous start angle
,sat = sa // Start angle
,ea = sa + this.angle(v) // Previous end angle
,eat = sat + a // End angle
@@ -242,6 +242,7 @@ $(function () {
,'tickWidth' : $this.data('tickWidth') || 0.02
,'tickColorizeValues' : $this.data('tickColorizeValues') || true
,'skin' : $this.data('skin') || 'default'
+ ,'angleOffset': degreeToRadians($this.data('angleoffset'))
// Hooks
,'draw' :
@@ -418,4 +419,8 @@ $(function () {
}
).parent();
};
+
+ function degreeToRadians (angle) {
+ return $.isNumeric(angle) ? angle * Math.PI / 180 : 0;
+ }
});
Please sign in to comment.
Something went wrong with that request. Please try again.