# js-swiper

> Beautiful swiper for React

Latest version **1.0.2** (published 2024-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-swiper
pnpm add js-swiper
yarn add js-swiper
bun add js-swiper
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-03-27 |
| First published | 2023-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 41.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | com_imjs |
| Maintainers | com_imjs |
| Keywords | react, nextjs, carousel, swipe, swiper |

## Links

- npm: https://www.npmjs.com/package/js-swiper
- Repository: https://github.com/comjs/js-swiper
- Homepage: https://github.com/comjs/js-swiper#readme
- Issues: https://github.com/comjs/js-swiper/issues
- npm.io page: https://npm.io/package/js-swiper

## Dependencies (5)

- [react](https://npm.io/package/react.md) ^18.2.0
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [typescript](https://npm.io/package/typescript.md) ^4.9.5
- [@emotion/react](https://npm.io/package/@emotion/react.md) ^11.10.6
- [@emotion/styled](https://npm.io/package/@emotion/styled.md) ^11.10.6

## 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.2 (latest) — 2024-03-27
- 1.0.1 — 2024-02-28
- 1.0.0 — 2024-02-28
- 0.1.6 — 2024-02-28
- 0.1.5 — 2024-02-28
- 0.1.4 — 2024-02-28
- 0.1.3 — 2024-02-28
- 0.1.2 — 2024-02-22
- 0.1.0 — 2023-03-06

## README

# Swiper
Beautiful swiper for React

## Demo


https://user-images.githubusercontent.com/107611589/222640699-2c32bfe6-2ae9-473b-b45f-f4ca41f96a71.mov



## Install
`npm install js-swiper`

## Usage

### For general
```Typescript
import {JSSwiper} from 'js-swiper'
import {JSSwiperData} from 'js-swiper/dist/cjs/src/lib/JSSwiper'

...

const stateEl = useRef<HTMLButtonElement>(null)

const itemList: JSSwiperData[] = [
  {order: 1, image: '/image8.png'},
  {order: 2, image: '/image9.png'},
  {order: 3, image: '/image10.png'},
]

...

<JSSwiper
  items={itemList}
  stateButton={stateEl.current}
  duration={200}
  interval={5000}
  onChangeItem={console.log}
  onChangeState={console.log}
/>
<button ref={stateEl}>Toggle State</button>
```

### For React development environment
> This feature is for About [useEffect called twice issue in React 18](https://github.com/facebook/react/issues/24553)

```Typescript
<JSSwiper
  ...
  startEffect="useEffectOnce"
 />
```
or
```Typescript
const useEffectOnce = (callback: React.EffectCallback, dependencyList: React.DependencyList | undefined) => {
  ...
}

...

<JSSwiper
  ...
  startEffect={useEffectOnce}
 />
```

## Properties
|Property|Default|Type|Description|
|---|:---:|---|---|
|items|undefined|extends [`JSSwiperData`](#jsswiperdata)||
|prevButton|undefined|extends `HTMLElement`||
|nextButton|undefined|extends `HTMLElement`||
|stateButton|undefined|extends `HTMLElement`||
|duration|200|`number`||
|interval|0|`number`||
|width|undefined|`number`||
|height|undefined|`number`||
|startEffect|undefined|`'useEffectOnce'` or [`useEffect type`](#typeof-useeffect)|[`For React dev environment`](#for-react-development-environment)|

<details>
<summary><a id="jsswiperdata">JSSwiperData</a></summary>

```Typescript
type JSSwiperData = {
  image: string
  order: number
  /** image styles */
  backgroundColor?: Property.BackgroundColor
  objectFit?: Property.ObjectFit
} & ({
  link: string
  newTab?: boolean
} | {
  link?: never
  newTab?: never
})
```
</details>

<details>
<summary><a id="typeof-useeffect">useEffect type</a></summary>

```Typescript
(callback: React.EffectCallback, dependencyList: React.DependencyList | undefined) => void
```
</details>

---
_Source: https://npm.io/package/js-swiper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
