• Stars
    star
    957
  • Rank 47,767 (Top 1.0 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ScrollView with an image in header which becomes a navbar

react-native-image-header-scroll-view

badge

A ScrollView-like component that:

  • Has a fixed image header
  • Keep the image as a nav bar
  • Works on iOS and Android

Breaking changes

Version 1.0.0

/!\ Warning /!\ The lib has been upgraded to match with new React and React Native standards (hooks, deprecated methods, etc...). The version 1.0.0 may contain some bugs or regressions. Ping me in issues if you notice a bad behaviour of the upgraded lib on your project. I advice you to update the lib in a separate commit to roll back if necessary. However the lib should work for most of cases, so don't be scared to update the lib. It is a first step to improve the lib in the future, so please be understanding 😇

Installation

$ npm install react-native-image-header-scroll-view --save

Demo

react-native-image-header-scroll-view demo android|react-native-image-header-scroll-view demo ios

You can find this example code here : https://github.com/bamlab/react-native-image-header-scroll-view-example/blob/master/src/Pages/TvShow.js

Basic Usage

import { ImageHeaderScrollView, TriggeringView } from 'react-native-image-header-scroll-view';

// Inside of a component's render() method:
render() {
  return (
    <ImageHeaderScrollView
      maxHeight={200}
      minHeight={MIN_HEIGHT}
      headerImage={require("../../assets/NZ.jpg")}
      renderForeground={() => (
        <View style={{ height: 150, justifyContent: "center", alignItems: "center" }} >
          <TouchableOpacity onPress={() => console.log("tap!!")}>
            <Text style={{ backgroundColor: "transparent" }}>Tap Me!</Text>
          </TouchableOpacity>
        </View>
      )}
    >
      <View style={{ height: 1000 }}>
        <TriggeringView onHide={() => console.log("text hidden")}>
          <Text>Scroll Me!</Text>
        </TriggeringView>
      </View>
    </ImageHeaderScrollView>
  );
}

Result :

Basic Usage

You can find examples in a dedicated repository.

Usage (API)

All of the properties of ScrollView are supported. Please refer to the ScrollView documentation for more detail.

The ImageHeaderScrollView handle also the following props. None is required :

Header

Property Type Default  Description Example
renderHeader function  Empty view Function which return the component to use as header. It can return background image for example. example
headerImage Image source Props (object or number)  undefined Shortcut for renderHeader={() => <Image source={this.props.headerImage} style={{ height: this.props.maxHeight, width: Dimensions.get('window').width }} />} example
maxHeight number 125 Max height for the header example
minHeight number 80 Min height for the header (in navbar mode) example
minOverlayOpacity number 0 Opacity of a black overlay on the header before any scroll example
maxOverlayOpacity number 0.3 Opacity of a black overlay on the header when in navbar mode example
overlayColor string black Color of the overlay on the header example
useNativeDriver boolean false Use native driver for the animation for performance improvement. A few props are unsupported at the moment if useNativeDriver=true (onScroll, ScrollComponent, renderTouchableFixedForeground) -
headerContainerStyle Object undefined Optional styles to be passed to the container of the header component
disableHeaderGrow boolean undefined Disable to grow effect on the header

Foreground

Property Type Default  Description Example
renderForeground function Empty view Function which return the component to use at foreground. The component is render in front of the header and scroll with the ScrollView. It can return a title for example. example
renderFixedForeground function Empty view Function which return the component to use as fixed foreground. The component is displayed with the header but not affected by the overlay. example
foregroundExtrapolate string clamp Optional prop that allows override extrapolate mode for foreground. Use null to allow extrapolation, which is usefull for using foreground as bottom title -
foregroundParallaxRatio number 1 Ration for parallax effect of foreground when scrolling. If 2, the header goes up two times faster than the scroll example
fadeOutForeground bool false If set, add a fade out effect on the foreground when scroll up example
renderTouchableFixedForeground function Empty view Same as renderFixedForeground but allow to use touchable in it. Can cause performances issues on Android example
fixedForegroundContainerStyles Object undefined Optional styles to be passed to the container of the fixed foreground component

Mixed

Property Type Default  Description Example
ScrollViewComponent Component  ScrollView The component to be used for scrolling. Can be any component with an onScroll props (ie. ListView, FlatList, SectionList or ScrollView) example
scrollViewBackgroundColor string  white Background color of the scrollView content example

TriggeringView

The module also export a TriggeringView component. It is a spy View you put on the page that will can call various callback during the scroll. It accept callback called when it disappear or appear at the top of the ImageHeaderScrollView. You can see an exemple in the dedicated repository.

All of the properties of View are supported.

Property Type Description
onBeginHidden function  Called when the component start to be hidden at the top of the scroll view.
onHide function  Called when the component is not displayed any more after scroll up
onBeginDisplayed function  Called when the component begin to be displayed again after scroll down
onDisplay function  Called when the component finished to be displayed again.
onTouchTop function  Called when the Top of the component touch the Top of the ScrollView. (onDisplay + onBeginHidden)
onTouchBottom function  Called when the Bottom of the component touch the Top of the ScrollView. (onHide + onBeginDisplayed)

FAQ

How to remove the black image overlay

Just set the maxOverlayOpacity to 0.

<ImageHeaderScrollView
  minOverlayOpacity={0}
  maxOverlayOpacity={0}
  {/* ... */}
/>

How to remove the image zomming on scroll down

You have two solutions :

  1. You can use the disableHeaderGrow props. It will keep the ios elastic scroll effect.
  2. You can also use the bounces={false} props from the scroll view.

Results :

disableHeaderGrow bounces={false}
react-native-image-header-scroll-view demo disableHeaderGrow react-native-image-header-scroll-view demo bounces

Contributing

All contributions are welcomed, that might be either adding new features, doing some refaco of the exisiting code or fixing bugs.

How to contribute

  1. Fork the project & clone locally. Follow the initial setup here.
  2. Create a branch, naming it either a feature or bug: git checkout -b feature/that-new-feature or bug/fixing-that-bug
  3. Code and commit your changes. Write a good commit message. Best would be to use git commitizen
  4. Test your changes in the example
  • launch the Expo project: cd example && yarn start && cd ..
  • compile typescript to lib folder : `yarn tsc --noEmit``
  • watch your feature/fix in your simulator
  1. Push to the branch: git push origin feature/that-new-feature
  2. Create a pull request for your branch 🎉

Other open-source modules by the folks at BAM

More Repositories

1

react-native-image-resizer

🗻 Resize local images with React Native
Java
1,514
star
2

generator-rn-toolbox

The React Native Generator to bootstrap your apps
JavaScript
1,195
star
3

flashlight

📱⚡️ Lighthouse for Mobile - audits your app and gives a performance score to your Android apps (native, React Native, Flutter..). Measure performance on CLI, E2E tests, CI...
TypeScript
864
star
4

react-native-make

A collection of everyday React Native CLI tools
TypeScript
765
star
5

react-native-flipper-performance-monitor

An attempt to have a lighthouse for React Native. Flipper plugin to show a graph of the React Native performance monitor
TypeScript
580
star
6

react-native-formik

Set of helpers to make form awesome with React Native and Formik
JavaScript
399
star
7

react-native-hide-with-keyboard

Wrap around components to hide them if keyboard is up
JavaScript
124
star
8

fastlane-plugin-cordova

Integrate your Cordova build into your Fastlane setup
Ruby
115
star
9

rn-camera-roll

Use the React native CameraRoll API with both Android & iOS
Java
110
star
10

redux-enhancer-react-native-appstate

Connect your App State changes directly to your Redux store
JavaScript
91
star
11

dev-standards

https://bamtech.gitbooks.io/dev-standards/
JavaScript
86
star
12

animation-demo

react native animation demo
JavaScript
73
star
13

react-tv-space-navigation

A React Native module to handle spatial navigation for a TV application
TypeScript
64
star
14

react-native-testing

Some examples, tools and tips on how to test a React Native app with react-native-testing-library
TypeScript
61
star
15

commentor

Commentor helps you analyze code review comments 📈
TypeScript
45
star
16

flow-navigator

A flow navigator for react-navigation
TypeScript
43
star
17

react-native-batch-push

⛔️ DEPRECATED : React Native integration of Batch.com push notifications SDK
TypeScript
41
star
18

bam-api

A GraphQL, "production ready"™ api for internal use at bam, but open sourced as an example !
JavaScript
39
star
19

react-native-components-collection

A collection of common React Native components
JavaScript
38
star
20

react-native-braintree-payments-drop-in

React Native integration of Braintree Drop-in
Java
35
star
21

react-native-stripe

Objective-C
32
star
22

nest-rabbit-tasks

nest-rabbit-worker is a TaskQueue based upon RabbitMQ for NestJS
TypeScript
30
star
23

react-native-numberpicker-dialog

Show a dialog on Android, allowing to choose an option using NumberPicker
Java
28
star
24

generator-module-react-native

Generate native module boilerplate for React Native iOS & Android
JavaScript
25
star
25

react-native-graphql-transformer

Transform GraphQL source files
JavaScript
22
star
26

react-native-app-security

Easily implement usual security measures in React Native Expo apps
Java
20
star
27

kstate

Kotlin MP State Machine Library
Kotlin
20
star
28

react-native-screen-sizer

A react native library to simulate different screen sizes on the same device
TypeScript
19
star
29

ecoappscore

18
star
30

adaptive_test

Devtools to write stunning widget test in Flutter. Made by BAM ❤️💙💛
C++
16
star
31

taiichi

Poka Yoke (on fire)
TypeScript
15
star
32

react-native-text-input

Provides Text Input component with colorization for password both on Android & iOS
Java
15
star
33

react-native-form-idable

JavaScript
14
star
34

react-native-image-header-scroll-view-example

Demo application for image-header-scroll-view library
JavaScript
14
star
35

easy-lottie-react-native

Lottie for React Native without hassle - UNMAINTAINED: improvements were upstreamed to lottie-react-native
JavaScript
14
star
36

android-live-coding

Kotlin
12
star
37

react-native-highlight-text

A react native module that hightlights given words in a text
JavaScript
11
star
38

rn-calabash-demo

How to add Calabash to a React Native project
Objective-C
10
star
39

CircleCI-Scripts

A boilerplate to build Cordova Application (iOS and Android) and release them with HockeyApp using Circle CI.
Shell
10
star
40

performance-monitoring

JavaScript
10
star
41

redux-enhancer-react-native-network

Connect redux to the network changes
JavaScript
10
star
42

collections-runner

automator
TypeScript
9
star
43

react-native-animated-picker

A picker for iOS that is displayed inside a keyboard and some other utils for custom keyboards
JavaScript
9
star
44

forest-admin-smart-views

A repo to gather forest admin smart views
JavaScript
8
star
45

google-calendar-counter

JavaScript
7
star
46

kettle

Kettle - The templating engine for boilerplates
TypeScript
6
star
47

devicelab-bot

A device lab manager to automatically install apps on all your devices
JavaScript
6
star
48

bam-dev-native-standards

HTML
6
star
49

conceptor

TypeScript
6
star
50

equatable_lint

Linting rules for Equatable package
Dart
5
star
51

estimator

Internal tool to help to estimate projects
TypeScript
5
star
52

react-native-project-config

Monorepo with packages for setting up ESLint, Typescript, Prettier and Jest.
TypeScript
5
star
53

open-source

Our open source repositories
4
star
54

react-native-stripe-sca

Stripe integration for react-native with SCA support
Ruby
4
star
55

bambi

BAM Beautiful (code) Inspection
JavaScript
3
star
56

react-native-ssl-pinning

Implements SSLPinning with expo-module and expo-plugin
TypeScript
3
star
57

a-gentle-introduction-to-mobile-development

Git Book
3
star
58

storybook-addon-react-native-deployment

Enable deployment of a storybook on your React Native app
JavaScript
3
star
59

typescript-patterns

3
star
60

formation-graphql

JavaScript
3
star
61

tuist-example

Showcasing a basic tuist application
Swift
2
star
62

ingenico-flutter-sdk

Flutter SDK for the Ingenico payment solution
Java
2
star
63

eslint-plugin-bam

JavaScript
2
star
64

formation-tech-lead-exercices

A good debugging exercise
JavaScript
2
star
65

react-navigation-live-reload-on-screen

TypeScript
2
star
66

tribe-native-rd-tateru-visionos

Swift
2
star
67

react-redux-toolbox

Set of utils for React and Redux development
JavaScript
2
star
68

www.bamlab.fr

CSS
2
star
69

android-navigable-bottom-sheet

Helps us to choose the best way to have navigable bottom sheet in compose
Kotlin
2
star
70

detoxFormation

Experiment with Detox & React Native
TypeScript
2
star
71

redux-crud-model

Generate reducer, actions creators and selectors to easily handle entity crud operation
JavaScript
2
star
72

cordova-plugin-native-routing

A Cordova plugin that allows you to call a native controller
Java
2
star
73

tuist-poc-healico

A proof of concept of Tuist to show how we can tame xcode complexity on a micro-feature architecture. Uses version 2.1.1 syntax.
Swift
2
star
74

flutter_dojo

Dart
2
star
75

team-mosaic-creator

Generate a mosaic of your team members' profile pictures
PHP
1
star
76

kotlin-open-source-template

Template for open source projects
HTML
1
star
77

parcel-plugin-handlebars-mock

JavaScript
1
star
78

nest-clean-code

TypeScript
1
star
79

dojo-snake

JavaScript
1
star
80

react-native-debugger-utils

JavaScript
1
star
81

hello-rust

A small Rust Hello World project to build rust programs for iOS/Android targets in order to run them from within a mobile app
1
star
82

formation-redux-refacto

How to refacto your redux
JavaScript
1
star
83

bamer_profiles_flutter

Small app to display BAMer profiles and their github info. Used for code audits and pair programming in flutter tech lead hiring progress
C++
1
star