question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to make transition animation?

See original GitHub issue

My English is not good, so sorry~~~ 😢

In React ecosystem, I make a easy transition animation by ReactTransitionGroup.

so, by Preact, how i do it ?

I just want easy css transition animation,like enter or leave.

Thank you

preact is awesome project, keep going! 👍

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
mindplay-dkcommented, Sep 17, 2018

I was hoping to find something more in the vein of Preact - something more minimal and more general that doesn’t require the react compatibility thing.

Picodom offers two simple element-level life-cycle hooks, oncreate and onremove:

https://github.com/picodom/picodom#life-cycle-attributes

oncreate is simple enough, and you can do something similar with the ref hook in Preact - but onremove is particularly interesting here, because it permits you to defer the physical removal of the DOM element to a later time.

So if you wanted animation during removal of keyed table-rows, you’d do something like this:

<tr key={ ... } onremove={ (el, done) => { el.classList.add("remove"); setTimeout(done, 1000) }}>
   ...
</tr>

If the framework is about to remove a DOM element with an onremove handler, instead of immediately removing the element, it passes a callback done to the handler, which can call it later to remove the actual element - in the mean time, the diff/patch algo ignores that element and leaves it where it is in the DOM.

I’d love to find a simpler way to do something similar in Preact, as my needs are pretty humble - essentially, I’d use animation to indicate table-rows or list-items being added/removed, purely to improve end-user’s perception of having created/destroyed something.

If you were going to hard-code a simple removal animation, without any framework at all, what would that minimally look like in Preact?

For creation, if you’re going to use a simple CSS transition, presumably you’d need a “next frame” callback of sorts - some way to defer the addition of a class until the render after the next scheduled render. Is there any way to hook into the internal rendering pipeline of Preact to make that happen?

4reactions
developitcommented, Apr 7, 2016

@neagle The issue is that react-addons-css-transition-group is actually just a proxy into React’s core. I’m working on a refactor/rewrite of rc-css-transition-group that improves it and makes it standalone. You can see how odd it is here:

https://npmcdn.com/react-addons-css-transition-group

module.exports = require('react/lib/ReactCSSTransitionGroup');
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using CSS transitions - CSS: Cascading Style Sheets | MDN
CSS transitions provide a way to control animation speed when changing CSS properties. Instead of having property changes take effect ...
Read more >
Video: Animations and transitions - Microsoft Support
In the Thumbnail Pane, select the slide where you want to apply or change a transition. · On the Transitions tab, find the...
Read more >
An Interactive Guide to CSS Transitions - Josh W Comeau
In this tutorial, we'll dig in and learn a bit more about CSS transitions, and how we can use them to create lush,...
Read more >
Six Essential Motion Design Transitions
The Six Essential Motion Design Transitions · 1. HARD CUT · 2. DISSOLVE · 3. CUT ON ACTION · 4. MATCH CUT.
Read more >
CSS Transitions - W3Schools
How to Use CSS Transitions? ... To create a transition effect, you must specify two things: ... Note: If the duration part is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found