-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss-gradient-string.js
More file actions
28 lines (27 loc) · 895 Bytes
/
css-gradient-string.js
File metadata and controls
28 lines (27 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// @note webkit only
//
// W.cssGradientString().add(0, "#FF0000").add(0, "#00FF00").add(0, "#0000FF").get();
var cssGradientString = function(stops) {
var values = [];
var _direction = "left"; // "top", "right", "bottom", "left", "-45.0deg"
var promise = {
direction : function (direction) {
_direction = direction;
return promise;
},
add : function (precentage, value) {
values.push([precentage, value]);
return promise;
},
get : function () {
var str = "-webkit-linear-gradient(" + _direction + ", ";
for (var i = 0; i<values.length; i++) {
str += values[i][1] + " " + values[i][0] + "%";
if (i<values.length-1) { str += ","; }
}
str += ")";
return str;
}
};
return promise;
};