Я пытался найти способ иметь возможность иметь заголовок, который перемещается с прокруткой в сочетании с коммутатором вкладок, который в определенной точке переходит в положение. Я смог заставить все это работать отлично, однако у меня есть одна проблема. Запустите вертикальный свиток при выполнении жеста прокрутки сверху. В настоящее время в заголовке прокручивается прокрутка ScrollView как его абсолютное расположение над ним, это просто кнопки и горизонтальные свитки, которые находятся в нем, которые не являются. < /P>
import { View } from 'react-native';
import Animated, { useAnimatedStyle, interpolate, interpolateColor } from 'react-native-reanimated';
import { TabView } from 'react-native-tab-view';
// import provider
import type { SceneRendererProps } from 'react-native-tab-view'
import { useScroll } from '~/utils/providers'
// import constants
import { Screen } from '~/components/layouts'
import { DefaultHeader } from '~/components/global'
// styles
import { Layout } from '~/styles'
// import styles
import { useStyles } from './style'
// import theme
import { useTheme } from '~/theme'
// import types
import type { IconsType } from '~/constants'
import type { TranslationString, TranslationStringWIthOptions } from '~/locales'
// define types
type ScreenWithHeaderProps = {
headerTitle: string | TranslationString | TranslationStringWIthOptions
headerRightIcons?: Array void }>
headerHeight?: number
topComponentHeight?: number
topComponent: React.ReactNode
tabBarHeight?: number
routes: Array
renderTabBar: (props: SceneRendererProps) => React.ReactNode
renderScene: (props: SceneRendererProps & { route: any }) => React.ReactNode
activeIndex: number
onIndexChange: (index: number) => void
}
export function ScreenCollapsableTabView({
headerTitle,
headerRightIcons,
headerHeight = 0,
topComponentHeight = 0,
tabBarHeight = 0,
topComponent,
routes,
renderTabBar,
renderScene,
activeIndex,
onIndexChange,
}: ScreenWithHeaderProps) {
// get styles file
const styles = useStyles()
// get theme data
const theme = useTheme()
// get scroll state and handler from content
const { scrollY } = useScroll()
const headerAnimatedStyle = useAnimatedStyle(() => ({
transform: [
{
translateY: interpolate(
scrollY.value,
[0, headerHeight + topComponentHeight],
[0, -(headerHeight + topComponentHeight)],
'clamp'
)
},
],
}))
// header backgroundcolor animation for on scroll change
const backgroundColorHeader = useAnimatedStyle(() => {
return {
backgroundColor: interpolateColor(
scrollY.value,
[0, 60],
['rgba(22, 33, 59, 0)', theme.colors.backgroundThird],
),
};
})
// animated tab bar transform & color
const tabBarAnimatedStyle = useAnimatedStyle(() => {
const translateY = interpolate(
scrollY.value,
[0, headerHeight + tabBarHeight],
[headerHeight + tabBarHeight, 0],
'clamp'
)
const backgroundColor =
scrollY.value
Подробнее здесь: https://stackoverflow.com/questions/794 ... -on-scroll
Отреагировать нативный анимационный заголовок на прокрутке ⇐ Javascript
Форум по Javascript
-
Anonymous
1741494647
Anonymous
Я пытался найти способ иметь возможность иметь заголовок, который перемещается с прокруткой в сочетании с коммутатором вкладок, который в определенной точке переходит в положение. Я смог заставить все это работать отлично, однако у меня есть одна проблема. Запустите вертикальный свиток при выполнении жеста прокрутки сверху. В настоящее время в заголовке прокручивается прокрутка ScrollView как его абсолютное расположение над ним, это просто кнопки и горизонтальные свитки, которые находятся в нем, которые не являются. < /P>
import { View } from 'react-native';
import Animated, { useAnimatedStyle, interpolate, interpolateColor } from 'react-native-reanimated';
import { TabView } from 'react-native-tab-view';
// import provider
import type { SceneRendererProps } from 'react-native-tab-view'
import { useScroll } from '~/utils/providers'
// import constants
import { Screen } from '~/components/layouts'
import { DefaultHeader } from '~/components/global'
// styles
import { Layout } from '~/styles'
// import styles
import { useStyles } from './style'
// import theme
import { useTheme } from '~/theme'
// import types
import type { IconsType } from '~/constants'
import type { TranslationString, TranslationStringWIthOptions } from '~/locales'
// define types
type ScreenWithHeaderProps = {
headerTitle: string | TranslationString | TranslationStringWIthOptions
headerRightIcons?: Array void }>
headerHeight?: number
topComponentHeight?: number
topComponent: React.ReactNode
tabBarHeight?: number
routes: Array
renderTabBar: (props: SceneRendererProps) => React.ReactNode
renderScene: (props: SceneRendererProps & { route: any }) => React.ReactNode
activeIndex: number
onIndexChange: (index: number) => void
}
export function ScreenCollapsableTabView({
headerTitle,
headerRightIcons,
headerHeight = 0,
topComponentHeight = 0,
tabBarHeight = 0,
topComponent,
routes,
renderTabBar,
renderScene,
activeIndex,
onIndexChange,
}: ScreenWithHeaderProps) {
// get styles file
const styles = useStyles()
// get theme data
const theme = useTheme()
// get scroll state and handler from content
const { scrollY } = useScroll()
const headerAnimatedStyle = useAnimatedStyle(() => ({
transform: [
{
translateY: interpolate(
scrollY.value,
[0, headerHeight + topComponentHeight],
[0, -(headerHeight + topComponentHeight)],
'clamp'
)
},
],
}))
// header backgroundcolor animation for on scroll change
const backgroundColorHeader = useAnimatedStyle(() => {
return {
backgroundColor: interpolateColor(
scrollY.value,
[0, 60],
['rgba(22, 33, 59, 0)', theme.colors.backgroundThird],
),
};
})
// animated tab bar transform & color
const tabBarAnimatedStyle = useAnimatedStyle(() => {
const translateY = interpolate(
scrollY.value,
[0, headerHeight + tabBarHeight],
[headerHeight + tabBarHeight, 0],
'clamp'
)
const backgroundColor =
scrollY.value
Подробнее здесь: [url]https://stackoverflow.com/questions/79495403/react-native-animated-header-on-scroll[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия