Permalink
Browse files

Fixes for angle parsing: don't reparse if value is 0; allow uppercase…

… units
  • Loading branch information...
1 parent 0d7a8eb commit cfd177411560c13074d5b3b1e5b46f1819065acc Jason Johnston committed Apr 28, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 sources/Angle.js
View
@@ -8,13 +8,13 @@ PIE.Angle = (function() {
this.val = val;
}
Angle.prototype = {
- unitRE: /(deg|rad|grad|turn)$/,
+ unitRE: /[a-z]+$/i,
/**
* @return {string} The unit of the angle value
*/
getUnit: function() {
- return this._unit || ( this._unit = this.val.match( this.unitRE )[1] );
+ return this._unit || ( this._unit = this.val.match( this.unitRE )[0].toLowerCase() );
},
/**
@@ -23,7 +23,7 @@ PIE.Angle = (function() {
*/
degrees: function() {
var deg = this._deg, u, n;
- if( !deg ) {
+ if( deg === undefined ) {
u = this.getUnit();
n = parseFloat( this.val, 10 );
deg = this._deg = ( u === 'deg' ? n : u === 'rad' ? n / Math.PI * 180 : u === 'grad' ? n / 400 * 360 : u === 'turn' ? n * 360 : 0 );

0 comments on commit cfd1774

Please sign in to comment.