Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An interactive sticky item inspired by Facebook Stories.

License

NotificationsYou must be signed in to change notification settings

gorhom/react-native-sticky-item

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npmnpmnpm

An interactive sticky item inspired by Facebook Stories.


Installation

yarn add @gorhom/sticky-item# ornpm install @gorhom/sticky-item

Also, you need to installreact-native-reanimated,react-native-gesture-handler &react-native-svg, and follow theirs installation instructions.

Usage

...importStickyItemFlatListfrom'@gorhom/sticky-item';// dummy dataconstdata=[...Array(20)].fill(0).map((_,index)=>({id:`item-${index}`}));// configsconstITEM_WIDTH=90;constITEM_HEIGHT=150;constSTICKY_ITEM_WIDTH=24;constSTICKY_ITEM_HEIGHT=24;constSTICKY_ITEM_BACKGROUNDS=['#222','#000'];constSEPARATOR_SIZE=8;constBORDER_RADIUS=10;constStickyItemView=({  x,  threshold,  itemWidth,  itemHeight,  stickyItemWidth,  stickyItemHeight,  separatorSize,  isRTL,})=>{constamazingAnimation={// here you add your custom interactive animation// based on the animated value `x`}return<Animated.Viewstyle={amazingAnimation}/>}constApp=()=>{// methodsconsthandleStickyItemPress=()=>Alert.alert('Sticky Item Pressed');// renderconstrenderItem=({ item, index})=>(<Viewkey={`item-${index}`}style={{backgroundColor:'red',width:ITEM_WIDTH,height:ITEM_HEIGHT,}}/>)return(<StickyItemFlatListitemWidth={ITEM_WIDTH}itemHeight={ITEM_HEIGHT}separatorSize={SEPARATOR_SIZE}borderRadius={BORDER_RADIUS}stickyItemWidth={STICKY_ITEM_WIDTH}stickyItemHeight={STICKY_ITEM_HEIGHT}stickyItemBackgroundColors={STICKY_ITEM_BACKGROUNDS}stickyItemContent={StickyItemView}onStickyItemPress={handleStickyItemPress}data={data}renderItem={renderItem}/>)}exportdefaultApp

Props

namedescriptionrequiredtypedefault
itemWidthItem's width.YESnumber
itemHeightItem's height.YESnumber
separatorSizeFlatList's separator width, * if you provideItemSeparatorComponent, you will need to setseparatorSize.NO*number10
borderRadiusItem & sticky border radius.NOnumber15
stickyItemActiveOpacitySticky item's active opacity.YESnumber0.25
stickyItemWidthSticky item's width.YESnumber
stickyItemHeightSticky item's height.YESnumber
stickyItemBackgroundColorsSticky item's two background colors, one when sticky item is extended another when it's minimize.YESstring[]
stickyItemContentSticky item's content component.YESReactNode
isRTLFlatList' layout direction.NObooleanfalse
onStickyItemPressCallback when sticky item gets pressed.NOfunction
...FlatList PropsReact Native FlatList props.NOFlatList

To Do

  • Write a detailed step-by-step instruction to create sticky interactive animation.
  • Add more examples.
  • Add vertical support ?.

Author

Sponsor & Support

To keep this library maintained and up-to-date please considersponsoring it on GitHub. Or if you are looking for a private support or help in customizing the experience, then reach out to me on Twitter@gorhom.

License

MIT

Built With ❤️


Mo Gorhom

About

An interactive sticky item inspired by Facebook Stories.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

 

[8]ページ先頭

©2009-2025 Movatter.jp