Permalink
Browse files

fix a minor bug with angleOffset

  • Loading branch information...
aterrien committed May 28, 2012
1 parent e470432 commit 31c003641d1acb7d97585fa433c0eba3ac495164
Showing with 12 additions and 12 deletions.
  1. +12 −12 js/jquery.knob.js
View
@@ -35,7 +35,7 @@ $(function () {
this.draw(nv);
} else {
var b, a;
- b = a = Math.atan2(mx - x, -(my - y - opt.width / 2));
+ b = a = Math.atan2(mx - x, -(my - y - opt.width / 2)) - opt.angleOffset;
(a < 0) && (b = a + PI2);
nv = Math.round(b * (opt.max - opt.min) / PI2) + opt.min;
return (nv > opt.max) ? opt.max : nv;
@@ -54,13 +54,13 @@ $(function () {
this.draw = function (nv) {
- var a = this.angle(nv) // 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
- ,r = opt.width / 2 // Radius
- ,lw = r * opt.thickness // Line width
+ var a = this.angle(nv) // 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
+ ,r = opt.width / 2 // Radius
+ ,lw = r * opt.thickness // Line width
,cgcolor = Dial.getCgColor(opt.cgColor)
,tick
;
@@ -242,7 +242,7 @@ $(function () {
,'tickWidth' : $this.data('tickWidth') || 0.02
,'tickColorizeValues' : $this.data('tickColorizeValues') || true
,'skin' : $this.data('skin') || 'default'
- ,'angleOffset': degreeToRadians($this.data('angleoffset'))
+ ,'angleOffset': degreeToRadians($this.data('angleoffset'))
// Hooks
,'draw' :
@@ -420,7 +420,7 @@ $(function () {
).parent();
};
- function degreeToRadians (angle) {
- return $.isNumeric(angle) ? angle * Math.PI / 180 : 0;
- }
+ function degreeToRadians (angle) {
+ return $.isNumeric(angle) ? angle * Math.PI / 180 : 0;
+ }
});

0 comments on commit 31c0036

Please sign in to comment.