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.

Animation issue (some delay appears)

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Some animations have bigger delay than expected

Expected Behavior

No animation delay

Steps To Reproduce

import { View as AnimationView } from 'moti'

const showBlock = () => {
    const [isExpanded, setIsExpanded] = useState(false)

<Pressable
				onPress={() => {
					setIsExpanded(!isExpanded)
				}}
			>
				<Box>
					<Text>External Block</Text>
				</Box>
				{isExpanded && (
					<AnimationView
						from={{ opacity: 0 }}
						animate={{ opacity: 1 }}
						transition={{ type: 'timing', duration: 180 }}
					>
						<Box>
							<Text>Internal Block</Text>
						</Box>
					</AnimationView>
				)}
			</Pressable>
}

Versions

- Moti: 0.20
- Reanimated: 2.9.1
- React Native: 0.69.6

Screenshots

https://user-images.githubusercontent.com/26281760/197521394-7878f201-c3e3-407b-941f-494e5482087e.mov

Reproduction

Reproducible very often

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pochampagnecommented, Nov 17, 2022

Any update on this ?

I’m having a similar issue. I created a simple component to reproduce. As seen on the video, sometime when I toggle my state to switch the visible component, the animation isn’t trigger, so the AnimatesView component remain in the “from” state, so with an opacity of 0.

const AnimatedView = ({ children }) => (
  <MotiView
    from={{
      opacity: 0,
      translateY: 20,
    }}
    animate={{
      opacity: 1,
      translateY: 0,
    }}
    exit={{
      opacity: 0,
      translateY: 20,
    }}
    transition={{
      type: 'timing',
      duration: 200,
    }}
  >
    {children}
  </MotiView>
)

export default () => {
  const [isOn, setIsOn] = React.useState<boolean>(true)

  const toggle = () => setIsOn((on) => !on)

  return (
    <View>
      <Pressable onPress={toggle}>
        <Text>Click me to toggle</Text>
      </Pressable>
      <AnimatePresence exitBeforeEnter>
        {isOn && (
          <>
            <Text>Toggle on outside MotiView</Text>
            <AnimatedView key="on">
              <Text>Toggle is on baby</Text>
            </AnimatedView>
          </>
        )}
        {!isOn && (
          <>
            <Text>Toggle off outside MotiView</Text>
            <AnimatedView key="off">
              <Text>Toggle is off sadly</Text>
            </AnimatedView>
          </>
        )}
      </AnimatePresence>
    </View>
  )
}
  • moti 0.20.0
  • reanimated 2.9.1
  • react-native 0.69.6
  • expo 46

https://user-images.githubusercontent.com/84029335/202496942-cf1f05ba-9a97-498a-9dc7-169916029ab0.MP4

0reactions
nandorojocommented, Nov 4, 2022

hmm that could indicate it’s due to reanimated versions. always kinda hard for me to say

Read more comments on GitHub >

github_iconTop Results From Across the Web

animation-delay - CSS: Cascading Style Sheets | MDN
The animation-delay CSS property specifies the amount of time to wait from applying the animation to an element before beginning to perform ...
Read more >
animation delay not working - Stack Overflow
Okay, I have this text that I want to appear after 20s. I am using the animation-delay property ...
Read more >
CSS Animations Not Working? Try These Fixes - HubSpot Blog
Accomplish this with the animation-delay property. Below, the animation has a delay of 4s (four seconds). This Pen is owned by HubSpot on ......
Read more >
[Fixed] Animation Delay not working CSS - Weekend Projects
This article will go through a few reasons why when using CSS animations and using the. animation-delay property is not working.
Read more >
Keyframe CSS Animation Delay Bug on iOS - Litmus
Found the solution: Use negative delay values. .words-1 span { position: absolute; opacity: 0; overflow: hidden; color: #6b969d; animation: ...
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