Animations, Transitions & Experiential Sites
See original GitHub issueHey there! I’m really enjoying Hyperapp so far. I’m trying to use it for building a rich/experiential/animated site (imagine lots of animations/transitions, WebGL/Canvas, etc) and it seems to have a couple of unique issues.
- When using
onremove
with a delayed callback (e.g. fade out), if the user quickly adds/removes the component from the tree they will end up with multiple of the same component. I am hoping for something closer to “React Transition Group” so that my view looks like this. But in this case I don’t want multiple error messages to stack up.
<div>
<TextField />
<TransitionGroup>
{state.isError ? <AnimatedErrorMessage /> : undefined}
</TransitionGroup>
</div>
- Right now, using
onremove
sometimes leads to an error:
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Full code to reproduce. Try clicking +/- really quickly.
import { h, app } from 'hyperapp';
const noop = () => {};
const state = {
count: 0
};
const actions = {
down: () => state => ({ count: state.count - 1 }),
up: () => state => ({ count: state.count + 1 })
};
const fadeIn = (el) => {
console.log('fade in', el);
};
const fadeOut = (el, done = noop) => {
console.log('fade out', el);
setTimeout(() => done(), 1000);
};
const animations = {
oncreate: fadeIn,
onremove: fadeOut
};
const Message = (state, children) => {
return <div {...state} {...animations}>Above one!</div>;
};
const view = (state, actions) => {
return <main>
<h1>{state.count}</h1>
<button onclick={actions.down}>-</button>
<button onclick={actions.up}>+</button>
{state.count >= 1 && <Message key='message' />}
</main>;
};
app(state, actions, view, document.body);
- This is more a question… I often end up needing local state in a component. I have seen a few issues mentioning this but they all point to different things: components, modules, mixins,
embed
utility functions that callapp()
, etc. I’m wondering what the official/suggested solution is for this?
For example: storing Canvas2D context for a component, or storing the millisecond time that the component was first created (but not replacing it on subsequent renders). I do not want to move all of this information into my global app state/actions.
Issue Analytics
- State:
- Created 6 years ago
- Comments:28 (20 by maintainers)
Top Results From Across the Web
Top 10 Websites With Outstanding Page Transition Animations
So let's inspire you with a list of 10 websites with outstanding page transition animations. 1. Total Property Network. Total Property Network.
Read more >10 Websites with Great Animation - School of Motion
10 Websites with Great Animation · Apple: iPad Pro · Stryve · Better Up: Inclusive Leadership Report · Croing Agency · Vibor ·...
Read more >Top 10 Websites With Outstanding Page Transition Animations
... look and increase the excitement of the user experience. So let's inspire you with a list of 10 websites with outstanding page...
Read more >Best Website Transition Examples - Blue Archer
Only animation and motion graphics judged. Best User Experience - Sites that offer the best user experience through innovative design, and ...
Read more >How CSS Animation, Transition and Transform Can Improve ...
In simple words, transitions are animated changes between two views or pages. Quick transitions can affect the user experience of a website, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here is a test case, it’s a bit wonky since I had to use setTimeout. You’ll see how it throws an error right now, but then if you replace
removeElement
with a safety check, the error will be gone but the test will fail as the elements won’t be removed.#663 helps a bit, that’s all I said. A definitive fix requires #499.