Skip to content

Commit 027c534

Browse files
committed
Support animation of SVG color properties
Animation of 'fill', 'flood-color', 'lighting-color', 'stop-color', 'stroke' is now supported.
1 parent fd1f41b commit 027c534

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/color-handler.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252

5353
scope.addPropertiesHandler(parseColor, mergeColors,
5454
['background-color', 'border-bottom-color', 'border-left-color', 'border-right-color',
55-
'border-top-color', 'color', 'outline-color', 'text-decoration-color']);
55+
'border-top-color', 'color', 'fill', 'flood-color', 'lighting-color',
56+
'outline-color', 'stop-color', 'stroke', 'text-decoration-color']);
5657
scope.consumeColor = scope.consumeParenthesised.bind(null, parseColor);
5758
scope.mergeColors = mergeColors;
5859

test/js/color-handler.js

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ suite('color-handler', function() {
2020
assert.equal(webAnimations1.propertyInterpolation('color', 'red', 'green')(2), 'rgba(0,255,0,1)');
2121
assert.equal(webAnimations1.propertyInterpolation('color', 'red', 'green')(-1), 'rgba(255,0,0,1)');
2222
});
23+
test('svg color interpolation', function() {
24+
assert.equal(webAnimations1.propertyInterpolation('fill', '#00fe00', '#180036')(0.5), 'rgba(12,127,27,1)');
25+
assert.equal(webAnimations1.propertyInterpolation('floodColor', '#00fe00', '#180036')(0.5), 'rgba(12,127,27,1)');
26+
assert.equal(webAnimations1.propertyInterpolation('lightingColor', '#00fe00', '#180036')(0.5), 'rgba(12,127,27,1)');
27+
assert.equal(webAnimations1.propertyInterpolation('stopColor', '#00fe00', '#180036')(0.5), 'rgba(12,127,27,1)');
28+
assert.equal(webAnimations1.propertyInterpolation('stroke', '#00fe00', '#180036')(0.5), 'rgba(12,127,27,1)');
29+
});
2330
test('interpolation to/from initial', function() {
2431
assert.equal(webAnimations1.propertyInterpolation('backgroundColor', 'initial', 'red')(0.5), 'rgba(255,0,0,0.500)');
2532
});

0 commit comments

Comments
 (0)