Skip to content

Conversation

DmitrySharabin
Copy link
Collaborator

No description provided.

Copy link

netlify bot commented Feb 21, 2025

Deploy Preview for style-observer ready!

Name Link
🔨 Latest commit 94928fb
🔍 Latest deploy log https://app.netlify.com/sites/style-observer/deploys/67b9d044a636460008c222c3
😎 Deploy Preview https://deploy-preview-90--style-observer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

if (!this.properties.has(event.propertyName)) {
if (event.type === "animationstart") {
let animation = document.getAnimations().find(a => a.effect.target === this.target);
let properties = this.getObservedAnimationProperties(animation);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure if this needs to be a separate function. It's only called once, and it seems to niche to be useful outside of this (but perhaps you plan to call it from somewhere else too?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. We don't need a separate function for this. I just thought it would make the code a bit cleaner. But it looks OK even with the inlined code.

Copy link
Owner

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very promising!

- Inline the code called once
- Add support for `animationThrottle` option
@DmitrySharabin
Copy link
Collaborator Author

I addressed your feedback (thank you!). What our next steps will be?


// Get the observed properties that are being animated by the animation
let keyframes = animation.effect.getKeyframes();
let properties = new Set(keyframes.flatMap(frame =>
Copy link
Collaborator Author

@DmitrySharabin DmitrySharabin Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a caveat: We can't get their names from the keyframes if we animate custom properties. 🤷‍♂️ See https://codepen.io/dmitrysharabin/pen/mydPGPR

On my local branch, I tried to add all observed custom properties to the properties array properties.push(...this.propertyNames.filter(property => property.startsWith("--")));.

It worked. But I still wonder, what if it's wrong... In that case, we will observe changes in computed properties even if the animation on the observed element changes properties we don't actually observe. I need to think about it a bit more. 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, Firefox does return custom properties when getting an animation's keyframes with getKeyframes().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants