Skip to content

Commit 31c0036

Browse files
committed
fix a minor bug with angleOffset
1 parent e470432 commit 31c0036

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

js/jquery.knob.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ $(function () {
3535
this.draw(nv);
3636
} else {
3737
var b, a;
38-
b = a = Math.atan2(mx - x, -(my - y - opt.width / 2));
38+
b = a = Math.atan2(mx - x, -(my - y - opt.width / 2)) - opt.angleOffset;
3939
(a < 0) && (b = a + PI2);
4040
nv = Math.round(b * (opt.max - opt.min) / PI2) + opt.min;
4141
return (nv > opt.max) ? opt.max : nv;
@@ -54,13 +54,13 @@ $(function () {
5454

5555
this.draw = function (nv) {
5656

57-
var a = this.angle(nv) // Angle
58-
,sa = 1.5 * Math.PI + opt.angleOffset // Previous start angle
59-
,sat = sa // Start angle
60-
,ea = sa + this.angle(v) // Previous end angle
61-
,eat = sat + a // End angle
62-
,r = opt.width / 2 // Radius
63-
,lw = r * opt.thickness // Line width
57+
var a = this.angle(nv) // Angle
58+
,sa = 1.5 * Math.PI + opt.angleOffset // Previous start angle
59+
,sat = sa // Start angle
60+
,ea = sa + this.angle(v) // Previous end angle
61+
,eat = sat + a // End angle
62+
,r = opt.width / 2 // Radius
63+
,lw = r * opt.thickness // Line width
6464
,cgcolor = Dial.getCgColor(opt.cgColor)
6565
,tick
6666
;
@@ -242,7 +242,7 @@ $(function () {
242242
,'tickWidth' : $this.data('tickWidth') || 0.02
243243
,'tickColorizeValues' : $this.data('tickColorizeValues') || true
244244
,'skin' : $this.data('skin') || 'default'
245-
,'angleOffset': degreeToRadians($this.data('angleoffset'))
245+
,'angleOffset': degreeToRadians($this.data('angleoffset'))
246246

247247
// Hooks
248248
,'draw' :
@@ -420,7 +420,7 @@ $(function () {
420420
).parent();
421421
};
422422

423-
function degreeToRadians (angle) {
424-
return $.isNumeric(angle) ? angle * Math.PI / 180 : 0;
425-
}
423+
function degreeToRadians (angle) {
424+
return $.isNumeric(angle) ? angle * Math.PI / 180 : 0;
425+
}
426426
});

0 commit comments

Comments
 (0)