Skip to content
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

[web-animations-2] Update OptionalEffectTiming.duration to accept CSSNumericValue #8949

Open
saschanaz opened this issue Jun 12, 2023 · 3 comments
Labels
web-animations-2 Current Work

Comments

@saschanaz
Copy link
Member

https://drafts.csswg.org/web-animations-2/#the-effecttiming-dictionaries

Web Animations Level 2 updates EffectTiming.duration with CSSNumericValue but not OptionalEffectTiming.duration. Maybe it should?

@birtles
Copy link
Contributor

birtles commented Jun 12, 2023

I think there's a note calling that out:

NOTE: In this version of the spec, duration is not settable as a CSSNumericValue; however, duration may be returned as a CSSNumericValue when resolving the duration in getComputedTiming(). Future versions of the spec may enable setting the duration as a CSSNumeric value, where the unit is a valid time unit or percent.

(I don't think I wrote it so I don't recall the background but just to say that this appears to be intentional.)

@saschanaz
Copy link
Member Author

Ah yes, OptionalEffectTiming is only for setting values I guess.

@romainmenke
Copy link
Member

romainmenke commented Jun 13, 2023

I initially reported this with TypeScript because I thought it was an issue there, not a spec issue.

For context, our use case is reading the current timing and adjusting that.
For this purpose it is important that these values can "round trip".

function reduceDuration( timing: EffectTiming ): OptionalEffectTiming {
	if ( 'auto' === timing.duration ) {
		timing.duration = 1;
	} else {
		timing.duration = timing.duration / 1000;
	}

	return timing;
}


keyframeEffect.updateTiming(
	reduceDuration(keyframeEffect.getTiming())
);

This has been used in production for years.

With the updated typings we get TS errors, but I now also fear that the implementations might change so that the actual code might also break in the future.

@SebastianZ SebastianZ added the web-animations-2 Current Work label Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-animations-2 Current Work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants