1

I have a styled component:

import styled, { keyframes } from 'styled-components';

const slideToCorner = keyframes`
  from {
    right: 0;
    top: 0;
  }

  to {
    right: 300px;
    top: 50px;
  }
`;

const SlideToCorner = styled.div`
  position: relative;
  right: 0;
  top: 0;
  ${props => props.slide && `animation: ${slideToCorner} 0.5s linear;`}
  transition: all 1s linear;
`;

export default SlideToCorner;

This is how it's being used:

<SlideToCorner slide={matchingStatus === MATCHING_STATES.CONFIRMING}>
  <TargetBox>
    <LocalVideo />
  </TargetBox>
</SlideToCorner>

However, when it animates it keeps resetting back to it's original position halfway through the animation:

enter image description here

I can confirm that it is not the matchingStatus === MATCHING_STATES.CONFIRMING that is causing it.

0

1 Answer 1

2

Add forwards in

animation: ${slideToCorner} 0.5s linear forwards

Or use animation-fill-mode: forwards

Check the animation-fill-mode property for different behaviors

Sign up to request clarification or add additional context in comments.

1 Comment

woahhhhhh it worked!! i've never seen animation-fill-mode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.