# react-native-swipe-close-image

> A package for swipe to close image in React native

Latest version **1.0.7** (published 2018-09-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-swipe-close-image
pnpm add react-native-swipe-close-image
yarn add react-native-swipe-close-image
bun add react-native-swipe-close-image
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2018-09-04 |
| First published | 2018-08-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | SieuThai |
| Maintainers | sieuhuflit |
| Keywords | React, native, swipe, to, close, image |

## Links

- npm: https://www.npmjs.com/package/react-native-swipe-close-image
- Repository: https://github.com/sieuhuflit/react-native-swipe-close-image
- Homepage: https://github.com/sieuhuflit/react-native-swipe-close-image#readme
- Issues: https://github.com/sieuhuflit/react-native-swipe-close-image/issues
- npm.io page: https://npm.io/package/react-native-swipe-close-image

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2018-09-04
- 1.0.6 — 2018-09-04
- 1.0.5 — 2018-09-03
- 1.0.4 — 2018-09-03
- 1.0.3 — 2018-09-03
- 1.0.2 — 2018-09-03
- 1.0.1 — 2018-09-03
- 1.0.0 — 2018-08-29

## README

# React native swipe close image

> A swipe close full screen image for Android and iOS

![](https://github.com/sieuhuflit/react-native-swipe-close-image/blob/master/demo.gif)

## Installation

```
npm install react-native-swipe-close-image --save
```

## Using

- Create SwipeCloseImage in render() with imageSource is the source of image (Can be local or remote url link)

```js
import SwipeCloseImage from 'react-native-swipe-close-image';
...
render() {
...
<SwipeCloseImage
  ref={c => (this.swipeToCloseRef = c)}
  imageSource={this.state.imageSource}
/>
...
}
```

- Then when want to open the image

```js
...
this.swipeToCloseRef.onOpen(this.imageRef);
...
```

### Code

```js
import SwipeCloseImage from 'react-native-swipe-close-image';

export default class App extends Component {
  onPressImage = () => {
    this.swipeToCloseRef.onOpen(this.imageRef);
    this.setState({
      imageSource:
        'https://facebook.github.io/react-native/docs/assets/favicon.png'
    });
  };

  render() {
    return (
      <View style={styles.container}>
        <TouchableWithoutFeedback onPress={this.onPressImage}>
          <Image
            ref={c => {
              this.imageRef = c;
            }}
            source={{
              uri:
                'https://facebook.github.io/react-native/docs/assets/favicon.png'
            }}
            resizeMode="contain"
            style={styles.imageStyle}
          />
        </TouchableWithoutFeedback>
        <SwipeCloseImage
          ref={c => (this.swipeToCloseRef = c)}
          imageSource={this.state.imageSource}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  imageStyle: {
    width: 250,
    height: 200
  }
});
```

[Example](./example/index.js)

## Props

| Prop            |      Default      |      Type       | Description                                          |
| :-------------- | :---------------: | :-------------: | :--------------------------------------------------- |
| imageSource     |     required      | `string,number` | Link of the source url (Can be local or remote link) |
| onOpen          |     required      |   `function`    | Function to open the image                           |
| resizeMode      |      Contain      |    `string`     | Resize mode for the image                            |
| backdropColor   | rgba(0,0,0,0.75)  |    `string`     | Backdrop color                                       |
| durationAnim    |        250        |    `number`     | Milisecond animation                                 |
| distanceDismiss | SCREEN_HEIGHT / 5 |    `number`     | Distance to auto dismiss close image                 |

## Author

Sieu Thai – sieuhuflit@example.com

[https://github.com/sieuhuflit](https://github.com/sieuhuflit/)

---
_Source: https://npm.io/package/react-native-swipe-close-image · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
