mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-13 16:33:28 -04:00
Move Item#opacity support to SVGStyles.
This commit is contained in:
parent
938433c51f
commit
7c1e10e35e
3 changed files with 7 additions and 13 deletions
|
@ -399,9 +399,7 @@ new function() {
|
|||
|
||||
function applyStyle(item, node) {
|
||||
var attrs = {},
|
||||
style = item.getStyle(),
|
||||
parent = item.getParent(),
|
||||
parentStyle = parent && parent.getStyle();
|
||||
parent = item.getParent();
|
||||
|
||||
if (item._name != null)
|
||||
attrs.id = item._name;
|
||||
|
@ -411,8 +409,8 @@ new function() {
|
|||
// (A layer or group which can have style values in SVG).
|
||||
var get = entry.get,
|
||||
type = entry.type,
|
||||
value = style[get]();
|
||||
if (!parentStyle || !Base.equals(parentStyle[get](), value)) {
|
||||
value = item[get]();
|
||||
if (!parent || !Base.equals(parent[get](), value)) {
|
||||
if (type === 'color' && value != null) {
|
||||
// Support for css-style rgba() values is not in SVG 1.1, so
|
||||
// separate the alpha value of colors with alpha into the
|
||||
|
@ -438,8 +436,8 @@ new function() {
|
|||
}
|
||||
});
|
||||
|
||||
if (item._opacity != null && item._opacity < 1)
|
||||
attrs.opacity = item._opacity;
|
||||
if (attrs.opacity === 1)
|
||||
delete attrs.opacity;
|
||||
|
||||
if (item._visibility != null && !item._visibility)
|
||||
attrs.visibility = 'hidden';
|
||||
|
|
|
@ -367,11 +367,6 @@ new function() {
|
|||
gradientTransform: applyTransform,
|
||||
transform: applyTransform,
|
||||
|
||||
opacity: function(item, value) {
|
||||
// http://www.w3.org/TR/SVG/masking.html#OpacityProperty
|
||||
item.setOpacity(parseFloat(value));
|
||||
},
|
||||
|
||||
'fill-opacity': applyOpacity,
|
||||
'stroke-opacity': applyOpacity,
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ var SVGStyles = Base.each({
|
|||
right: 'end'
|
||||
}],
|
||||
font: ['font-family', 'string'],
|
||||
fontSize: ['font-size', 'number']
|
||||
fontSize: ['font-size', 'number'],
|
||||
opacity: ['opacity', 'number']
|
||||
}, function(entry, key) {
|
||||
var part = Base.capitalize(key),
|
||||
lookup = entry[2];
|
||||
|
|
Loading…
Reference in a new issue