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 jittery even though fps stays at 60fps

See original GitHub issue

Description

Scrollview scroll with modifying the height of the header is super jittery. The only device it works on properly is iPad Pro. All iPhones it does not work well. Test devices iPhone 11 Pro, iPhone 6 and iPad Pro. Also it appears to just be on momentum scroll. (The event throttle is 1).

Screenshots

video

Steps To Reproduce

See code below.

Expected behavior

Smooth height animation.

Actual behavior

Jittery animation.

Snack or minimal code example

import React from 'react';
import { View, StyleSheet } from 'react-native';
import Animated, { interpolate, useSharedValue, useAnimatedStyle, useAnimatedScrollHandler, Extrapolate } from 'react-native-reanimated';

function ScrollExample() {
  const y = useSharedValue(0);

  const scrollHandler = useAnimatedScrollHandler((event) => {
    y.value = event.contentOffset.y;
  });

  const stylez = useAnimatedStyle(() => {
    const height = interpolate(y.value, [-100, 0, 200], [500, 400, 100], Extrapolate.CLAMP)
    return {
      height: height,
      // zIndex: height > 100 ? 0 : 1,
    };
  });

  console.log('render');

  return (
    <View style={{flex: 1, backgroundColor: '#f1f2f3'}}>
      <Animated.View style={[{backgroundColor: '#fab', ...StyleSheet.absoluteFill, bottom: null }, stylez]} />
      <Animated.ScrollView
        contentContainerStyle={{paddingTop: 300}}
        onScroll={scrollHandler}
        scrollEventThrottle={1}>
        <View style={{height: 200, margin: 20, marginBottom: 0, backgroundColor: '#fff', borderWidth: StyleSheet.hairlineWidth, borderColor: '#ccc', borderRadius: 8}} />
        <View style={{height: 200, margin: 20, marginBottom: 0, backgroundColor: '#fff', borderWidth: StyleSheet.hairlineWidth, borderColor: '#ccc', borderRadius: 8}} />
        <View style={{height: 200, margin: 20, marginBottom: 0, backgroundColor: '#fff', borderWidth: StyleSheet.hairlineWidth, borderColor: '#ccc', borderRadius: 8}} />
        <View style={{height: 200, margin: 20, marginBottom: 0, backgroundColor: '#fff', borderWidth: StyleSheet.hairlineWidth, borderColor: '#ccc', borderRadius: 8}} />
        <View style={{height: 200, margin: 20, marginBottom: 0, backgroundColor: '#fff', borderWidth: StyleSheet.hairlineWidth, borderColor: '#ccc', borderRadius: 8}} />
        <View style={{height: 200, margin: 20, marginBottom: 0, backgroundColor: '#fff', borderWidth: StyleSheet.hairlineWidth, borderColor: '#ccc', borderRadius: 8}} />
      </Animated.ScrollView>
    </View>
  );
}

export default ScrollExample

Package versions

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
arthurgeron-workcommented, Apr 14, 2022

I’m on 2.5.0, and if a element inside my scroll is animating with interpolation while the user is scrolling the scroll jitters…

2reactions
jakub-gonetcommented, Nov 9, 2020

This should be resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do some games feel smooth at 60fps while other ... - Reddit
In this case, example B would look very jittery as some frames would have the distinct appearance of sticking for a moment before...
Read more >
Choppy Gameplay but High FPS - What to Do? - Driver Support
If you are experiencing choppy gameplay, but have a high FPS, your driver could be to blame. Learn how to automatically update drivers...
Read more >
Why is the game 60 fps on PC? Its killing my eyes
You'll notice the intros run at a much slower framerate; that's not because the engine can't handle faster speed, but rather because it...
Read more >
60 fps to 30 fps makes movements jittery on mobile device
2D movement/scrolling looks particularly bad at lower frame rates, while into-the-screen motion doesn't look so bad. It's also possible that bad ...
Read more >
When playing some games, there are very noticeable ... - Quora
You can actually be getting 100fps and have a jerky game. This is because each frame is not always rendered in the same...
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