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

new primitive: transition, similar to modifiers, except they block certain render events #921

Open
NullVoxPopuli opened this issue Mar 29, 2023 · 2 comments

Comments

@NullVoxPopuli
Copy link
Sponsor Contributor

NullVoxPopuli commented Mar 29, 2023

I don't know if this is feasible yet, but i was just looking at svelte, and https://twitter.com/ankurpsinghal/status/1640842168288919552?s=20
It seems that they may have transition managers, much like how we have modifier managers, so different animation implementations could be built on top of that.

Why not use modifiers? Modifiers don't and can't block the removal of an element from the DOM.

Thoughts?

Examples:

Alternatively, if the modifier manager had an option for blocking removal, we could probably reuse more code.
We would also need #883 for pre-paint timing, so animations could have a proper initial state

@miguelcobain
Copy link
Contributor

Big yes to this. Ember needs more useful primitives for animation.

ember-css-transitions approach to animating out an element is to clone it. That often works fine, but sometimes it opens up all kinds of problems.
One example where I've seen it break is when the elements to be cloned have web-components, for example. Basically, cloning the DOM might have side-effects that you might not want. Also, it's probably expensive to do.

@lifeart
Copy link

lifeart commented Aug 4, 2023

We may have "poc" with modifier and glimmer opcode removal patch https://github.com/glimmerjs/glimmer-vm/blob/664a746b3baf82221c5874a759279d1afdd41e5b/packages/%40glimmer/runtime/lib/vm/element-builder.ts#L474C5-L474C12
Once modifier is installed, we adding node to AnimationMap, and once it's going to be removed (modifier uninstall), we could add additional removal logic into set.

And patched glimmer-vm logic may look into this set, and compare current node to remove with AnimationSet, and skip/delay removal.

Sample removal patch:

modifier logic:

window.AnimationMap = new WeakMap();

function animationModifier(element) {
     window.AnimationMap.add(element, async function() {
       await anyElementTransition();
     });
}

sample glimmer remove opcode:

export function removeElement(element) {
  if (window.AnimationMap.has(element)) {
   const instructions = window.AnimationMap.get(element);
   instructions(element).finally(()=>{
     element.parentNode.removeChild(element);
   });
  } else {
   element.parentNode.removeChild(element);
 }
}

Since glimmer removing nodes inside-out, we may need to check for every node.parentNode to be in window.AnimationMap

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

No branches or pull requests

3 participants