Skip to content

Commit

Permalink
to top left -- bottom right etc. support
Browse files Browse the repository at this point in the history
  • Loading branch information
kizu authored and notslang committed Jul 31, 2013
1 parent 3d57d9b commit 5841522
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/nodes/vendor-helpers.js
Expand Up @@ -15,13 +15,17 @@ module.exports = function(value) {
var result = value.toString();

if (result.indexOf('gradient(') > -1) {
result = result.replace(/(\(\s*)(?:(-?(\d*\.)?\d+)deg|to (top|bottom|left|right))/g,function(match,p1,p2,p3,p4){
result = result.replace(/(\(\s*)(?:(-?(\d*\.)?\d+)deg|to (top|bottom|left|right)( (top|bottom|left|right))?)/g,function(match,p1,p2,p3,p4,p5,p6){
var result = p1;
var sides = {'top':'bottom','bottom':'top','left':'right','right':'left'};
if (p2) {
result += parseFloat((Math.abs(450 - p2) % 360).toFixed(3)) + 'deg';
}
if (p4) {
result += {'top':'bottom','bottom':'top','left':'right','right':'left'}[p4];
result += sides[p4];
}
if (p5) {
result += ' ' + sides[p6];
}
return result;
});
Expand Down

0 comments on commit 5841522

Please sign in to comment.