Fix stutter when swiping feeds on Android (#6765)
This commit is contained in:
@@ -1,10 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {
|
import {SharedValue, useSharedValue, withSpring} from 'react-native-reanimated'
|
||||||
cancelAnimation,
|
|
||||||
SharedValue,
|
|
||||||
useSharedValue,
|
|
||||||
withSpring,
|
|
||||||
} from 'react-native-reanimated'
|
|
||||||
|
|
||||||
type StateContext = {
|
type StateContext = {
|
||||||
headerMode: SharedValue<number>
|
headerMode: SharedValue<number>
|
||||||
@@ -42,14 +37,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
const setMode = React.useCallback(
|
const setMode = React.useCallback(
|
||||||
(v: boolean) => {
|
(v: boolean) => {
|
||||||
'worklet'
|
'worklet'
|
||||||
// Cancel any existing animation
|
|
||||||
cancelAnimation(headerMode)
|
|
||||||
headerMode.set(() =>
|
headerMode.set(() =>
|
||||||
withSpring(v ? 1 : 0, {
|
withSpring(v ? 1 : 0, {
|
||||||
overshootClamping: true,
|
overshootClamping: true,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
cancelAnimation(footerMode)
|
|
||||||
footerMode.set(() =>
|
footerMode.set(() =>
|
||||||
withSpring(v ? 1 : 0, {
|
withSpring(v ? 1 : 0, {
|
||||||
overshootClamping: true,
|
overshootClamping: true,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, {useCallback, useEffect} from 'react'
|
import React, {useCallback, useEffect} from 'react'
|
||||||
import {NativeScrollEvent} from 'react-native'
|
import {NativeScrollEvent} from 'react-native'
|
||||||
import {
|
import {
|
||||||
cancelAnimation,
|
|
||||||
interpolate,
|
interpolate,
|
||||||
makeMutable,
|
makeMutable,
|
||||||
useSharedValue,
|
useSharedValue,
|
||||||
@@ -43,7 +42,6 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
|||||||
const setMode = React.useCallback(
|
const setMode = React.useCallback(
|
||||||
(v: boolean) => {
|
(v: boolean) => {
|
||||||
'worklet'
|
'worklet'
|
||||||
cancelAnimation(headerMode)
|
|
||||||
headerMode.set(v ? V1.get() : V0.get())
|
headerMode.set(v ? V1.get() : V0.get())
|
||||||
},
|
},
|
||||||
[headerMode],
|
[headerMode],
|
||||||
@@ -149,8 +147,6 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
|||||||
const newValue = clamp(startModeValue + dProgress, 0, 1)
|
const newValue = clamp(startModeValue + dProgress, 0, 1)
|
||||||
if (newValue !== headerMode.get()) {
|
if (newValue !== headerMode.get()) {
|
||||||
// Manually adjust the value. This won't be (and shouldn't be) animated.
|
// Manually adjust the value. This won't be (and shouldn't be) animated.
|
||||||
// Cancel any any existing animation
|
|
||||||
cancelAnimation(headerMode)
|
|
||||||
headerMode.set(newValue)
|
headerMode.set(newValue)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user