computerjazz / react-native-infinite-pager

An infinitely-swipeable pager component.
MIT License
175 stars 16 forks source link

Text is on top of each other if no background color is set on page #4

Closed RichardLindhout closed 2 years ago

RichardLindhout commented 2 years ago

Example without background color results first render with things on top of each other. If you do some gesture on it it fixes itself. If you have white background the bug is not visible anymore.

Schermafbeelding 2022-06-10 om 18 34 57 Schermafbeelding 2022-06-10 om 18 35 03
computerjazz commented 2 years ago

What version are you using? There was a fix for this in 0.0.12. Also, what version of reanimated?

wbercx commented 2 years ago

So using 0.0.12 and Reanimated 2.2.3, I do briefly see overlapping pages on the initial render. Giving the pages a background color makes it so that it briefly shows page 1 before correcting to page 0, which is still a bit jarring.

Below is admittedly an absolute hackjob, but works because focusAnim currently shortcircuits to 99999 when there is no pageWidth. This gives page 0 priority and makes the others initially invisible.

    const animStyle = useAnimatedStyle(() => {
-      // Short circuit page interpolation to prevent buggy initial values due to possible race condition:
-      // https://github.com/software-mansion/react-native-reanimated/issues/2571
-     if (!pageWidth.value) return {};
      return pageInterpolatorRef.current({
        focusAnim,
        pageAnim,
-       pageWidth,
+       pageWidth: (index !== 0 && !pageWidth.value) ? focusAnim : pageWidth,
        index,
      });
    }, [pageWidth, pageAnim, index, translation]);
computerjazz commented 2 years ago

your "hackjob" works great @wbercx , thanks! Released in https://github.com/computerjazz/react-native-infinite-pager/releases/tag/v0.1.0

nicolaosm commented 8 months ago

Why was this "hackjob" removed in newer commits and releases? The issue is happening on my end now...

nicolaosm commented 8 months ago

Any idea about what happened to the fix @computerjazz ? It doesn't to be there anymore and im getting this issue on slow devices. Thanks

computerjazz commented 8 months ago

@nicolaosm just pushed a fix, try again with latest?

nicolaosm commented 7 months ago

Thanks @computerjazz , will test this out and let you know.