SlideUp and SlideDown break when switching too fast #185
Comments
This is likely a consequence of See the demo for how these behaviors differ when calling |
Ah I see how the demo does it. But this feels more like a workaround than the way it should be to be honest.. This forces me to directly use the Velocity API instead of using this wrapper in a nice way.. Edit: OK so Especially because the docs say
But this change is happening in response to a state change. |
The same sort of configuration that is used in `runAnimation` could be
added to the props for VelocityComponent, if you're interested in sending
in a PR. It's all a workaround for slideUp/slideDown's implementation.
…On Tue, Apr 18, 2017 at 9:35 AM, Robin ***@***.***> wrote:
Ah I see how the demo does it. But this feels more like a workaround than
the way it should be to be honest.. This forces me to directly use the
Velocity API instead of using this wrapper in a nice way..
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#185 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAP65Xqb1JCOAGk0UE_zFiDvMaLVfim-ks5rxLwrgaJpZM4NAEoA>
.
|
@finneganh wouldn't it be better to add a prop to the velocity component? That way in What do you think? |
Yep, I think we're on the same page.
…On Tue, Apr 18, 2017 at 10:01 AM, Robin ***@***.***> wrote:
@finneganh <https://github.com/finneganh> wouldn't it be better to add a
prop to the velocity component? That way in componentWillUpdate we can
check for that prop. If prop==='stop' then stopAnimation, otherwise
finishAnimation.
What do you think?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#185 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAP65aPsI1m_ax7XF0Li_LQL9mgCs4AJks5rxMJLgaJpZM4NAEoA>
.
|
I'll make a PR in that case. |
Added the PR. Let me know if you agree or if you need changes. P.S.: I also tried updating the demo, but in the demo the |
I'm working on updating the demo to be hosted on Glitch. Will see if there's a good place to put it in then. |
Cool, this is now live. |
@finneganh I tried it out but it still doesn't seem to have the desired effect. I will check it out once more once I have some time. |
I think I figured out why this is happening. Velocity is using Promises and returns a Promise for most functions. Yet in |
Interesting. I believe that the Promise bits have been added since velocity-react was written. I can take a look. This will probably help if things like stop / finish are actually asynchronous, but not if the Promises are just an alternative to the |
@finneganh Any updates on that ? Having the same issue, but can't control anything if I use the VelocityTransitionGroup component 😢 |
I ran into this issue today, and had an idea. Velocity accepts a And that works! class MyVelocity extends React.Component {
constructor(props) {
super(props);
// https://reactjs.org/docs/handling-events.html
this.begin = this.begin.bind(this);
}
begin(elements) {
if ( 'slideDown' === this.props.animation ) {
elements.forEach((el) => {
if ( 'none' === el.style.display ) {
el.style.height = null;
}
});
}
}
render() {
const props = Object.assign({}, {begin: this.begin}, this.props);
return (
<VelocityComponent {...props}>
{this.props.children}
</VelocityComponent>
);
}
} Now you just use It's a bandaid, but for anyone tearing their hair out about this, I hope this helps. |
If you switch the
animation
prop betweenslideUp
andslideDown
too fast, the animation kinda breaks, as in, it becomes stuck in this in between state where it has almost no height.It seems that this is caused by the fact that both of these animations take the current height as the starting height instead of the original height. This is causing problems if you switch between the animations in the middle of the animation, e.g. by clicking on a Read more/Read less button really fast.
The text was updated successfully, but these errors were encountered: