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

Scope keyframe names defined in <style scoped> #237

Merged
merged 2 commits into from
May 5, 2020
Merged

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented May 5, 2020

When defined @keyframes in <style scoped>, Marpit will scope the keyframe name, and replace the keyframe name defined in animation and animation-name declarations within <style scoped> into scoped keyframe.

It's helpful for defining slide animations without thinking about confliction with global animation keyframes.

<style scoped>
@keyframes local-animation {
  from { transform: translateX(100%); }
  to { transform: none; }
}
h1 {
  animation: 1s ease-out local-animation;
}
</style>

The above definition will transform into this:

@keyframes local-animation-RVSdalDm {
  from { transform: translateX(100%); }
  to { transform: none; }
}

div.marpit > section[data-marpit-scope-RVSdalDm] h1 {
  animation: 1s ease-out local-animation-RVSdalDm;
}

Marpit will replace only animation names defined by <style scoped> in the same slide. So global animation keyframes are still working.

Resolves #231.

@yhatt yhatt merged commit 6738133 into master May 5, 2020
@yhatt yhatt deleted the scoped-keyframes branch May 5, 2020 11:06
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.

Support CSS Animation keyframes within the scoped style
1 participant