Permalink
Browse files

to top left -- bottom right etc. support

  • Loading branch information...
1 parent 3d57d9b commit 58415227f4d3e2a3f32ad62af8e4e2ad13df17a6 @kizu kizu committed with slang800 Oct 10, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/nodes/vendor-helpers.js
View
8 lib/nodes/vendor-helpers.js
@@ -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;
});

0 comments on commit 5841522

Please sign in to comment.