Fast path for initial styles
This commit is contained in:
@@ -65,9 +65,7 @@ export function TabBar({
|
|||||||
// We'll re-sync it here (with an animation) if you interact with the pager again.
|
// We'll re-sync it here (with an animation) if you interact with the pager again.
|
||||||
// From that point on, it'll remain synced again (unless you scroll the tabbar again).
|
// From that point on, it'll remain synced again (unless you scroll the tabbar again).
|
||||||
useAnimatedReaction(
|
useAnimatedReaction(
|
||||||
() => {
|
() => dragState.value,
|
||||||
return dragState.value
|
|
||||||
},
|
|
||||||
(nextDragState, prevDragState) => {
|
(nextDragState, prevDragState) => {
|
||||||
if (
|
if (
|
||||||
nextDragState !== prevDragState &&
|
nextDragState !== prevDragState &&
|
||||||
@@ -121,6 +119,9 @@ export function TabBar({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const indicatorStyle = useAnimatedStyle(() => {
|
const indicatorStyle = useAnimatedStyle(() => {
|
||||||
|
if (!_WORKLET) {
|
||||||
|
return {opacity: 0}
|
||||||
|
}
|
||||||
const layoutsValue = layouts.get()
|
const layoutsValue = layouts.get()
|
||||||
if (
|
if (
|
||||||
layoutsValue.length !== itemsLength ||
|
layoutsValue.length !== itemsLength ||
|
||||||
@@ -238,14 +239,19 @@ function TabBarItem({
|
|||||||
onItemLayout: (index: number, layout: {x: number; width: number}) => void
|
onItemLayout: (index: number, layout: {x: number; width: number}) => void
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const style = useAnimatedStyle(() => ({
|
const style = useAnimatedStyle(() => {
|
||||||
|
if (!_WORKLET) {
|
||||||
|
return {opacity: 0.7}
|
||||||
|
}
|
||||||
|
return {
|
||||||
opacity: interpolate(
|
opacity: interpolate(
|
||||||
dragProgress.get(),
|
dragProgress.get(),
|
||||||
[index - 1, index, index + 1],
|
[index - 1, index, index + 1],
|
||||||
[0.7, 1, 0.7],
|
[0.7, 1, 0.7],
|
||||||
'clamp',
|
'clamp',
|
||||||
),
|
),
|
||||||
}))
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const handleLayout = useCallback(
|
const handleLayout = useCallback(
|
||||||
(e: LayoutChangeEvent) => {
|
(e: LayoutChangeEvent) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user