-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-images-4] Animations should be allowed on linear/radial gradients #3783
Comments
Hi @SetTrend. I think everyone in the working group agrees with you that this should be possible. The problem is that there are a lot of little details that still need to be sorted out. The relevant specification is CSS Images Level 4. It was initially described in Level 3, but got pushed back because browser implementations weren't always consistent. (For a while, Chrome also supported some gradient animations.) Also, the current definition relies on falling back to So, what can you do?
|
Hi @AmeliaBR , thanks for replying. I couldn't find corresponding issues yet, so I created two issues now, both back-referencing this issue:
Anyone who's interested, please upvote there and here. |
Just let me add an example depicting that IE and MS Edge even interpolate angle and color of linear gradients: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
div
{
margin: 1em;
}
@keyframes movement1
{
from
{
background: linear-gradient(0deg, white, white 0%, #aaf 0%, white 2%, white);
}
25%
{
background: linear-gradient(90deg, white, white 25%, red 50%, white 52%, white);
}
50%
{
background: linear-gradient(180deg, white, white 98%, #aaf 99%, white 100%, white);
}
75%
{
background: linear-gradient(90deg, white, white 48%, purple 50%, white 75%, white);
}
to
{
background: linear-gradient(0deg, white, white 0%, #aaf 1%, white 2%, white);
}
}
input[type="text"]#i1
{
animation: 2s linear infinite movement1;
border: 1px solid silver;
border-radius: .5ex;
}
</style>
</head>
<body>
<div>
<input type="text" id="i1" />
</div>
</body>
</html> |
As a drive-by note, the css-background spec actually doesn't allow interpolation of background-images - it is defined as discretely interpolated. See #578 where alancutter long ago tried to get some attention to this. Chrome violates this for url() (see the 'background-image' line of the WPT test results, but we'd really rather not be violating the spec (either by removing it from Chrome or spec-ing interpolation in background-image) |
This issue is in fact about amending the spec to allow animations on gradients, which can be interpolated fine. I couldn't think of any kinf of animation on background-images (i.e. discrete image files) other than fading. |
Right, but a What I was pointing out is that now matter how we spec interpolation of gradients, unless we fix #578 we will not be able to interpolate the |
Under the new definition of "animatable", background-image is animatable, but as a discrete value. If we introduce a way for certain types of images to animate continuously, yes, that would need to be updated. |
Wouldn't this (I'm quoting your phrase now) "certain type of image" be a vector image in contrast to raster images? Probably only a certain fraction of vector images may be able to get morphed - vector images sharing the same number of primitives, for instance. There are algorithms available that morph different primitive shapes into each other. A circle, for instance, can be morphed into a hexagon. I guess the same applies to fill/pen brushes, too (as we can see from the Internet Explorer rendering above). |
CSS animations should explicitly allow animated
linear-gradient()
andradial-gradient()
backgrounds.If all
<keyframe-selector>
s of an animation yield computed background values sharing the same set of properties:linear-gradient()
,radial-gradient
,repeating-linear-gradient()
orrepeating-radial-gradient()
<color-stop>
valuesThen animation should take place in the form that the
<color-stop>
values should get animated over time.Internet Explorer and Microsoft Edge already implement this behaviour:
Sample Code
The text was updated successfully, but these errors were encountered: