# react-rolling-item

> Item rollers like slot machines for react

Latest version **0.5.5** (published 2020-01-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-rolling-item
pnpm add react-rolling-item
yarn add react-rolling-item
bun add react-rolling-item
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.5 |
| Published | 2020-01-21 |
| First published | 2019-06-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Byeongjin An |
| Maintainers | bye0jin |
| Keywords | react, roller, slot-machine, typescript |

## Links

- npm: https://www.npmjs.com/package/react-rolling-item
- Repository: https://github.com/ahnbj2000/react-rolling-item
- Homepage: https://ahnbj2000.github.io/react-rolling-item
- Issues: https://github.com/ahnbj2000/react-rolling-item/issues
- npm.io page: https://npm.io/package/react-rolling-item

## 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

- 0.5.5 (latest) — 2020-01-21
- 0.5.4 — 2020-01-21
- 0.5.3 — 2020-01-10
- 0.5.2 — 2020-01-08
- 0.5.1 — 2020-01-08
- 0.5.0 — 2019-11-26
- 0.4.9 — 2019-11-25
- 0.4.8 — 2019-11-25
- 0.4.7 — 2019-11-25
- 0.4.6 — 2019-11-25
- 0.4.5 — 2019-09-06
- 0.4.4 — 2019-09-05
- 0.4.32 — 2019-09-05
- 0.4.31 — 2019-09-05
- 0.4.3 — 2019-09-05
- … 73 more at https://npm.io/package/react-rolling-item/versions

## README

# react-rolling-item

## example

<img src="./public/ReactRollingItem_demo_gif.gif" width="600" height="250" />

```react
<>
  <RollingItem
    on={this.state.start}
    column={3}
    backgroundImage={imageFile}
    backgroundSize="600px 564px"
    introItemInfo={{ x: -39, y: -28 }}
    itemInfo={
      [
        { x: -39, y: -217, id: 'item_1', probability: 0 },
        { x: -39, y: -406, id: 'item_2', probability: 0 },
        { x: -241, y: -28, id: 'item_3', probability: 0 },
        { x: -241, y: -217, id: 'item_4', probability: 0 },
        { x: -241, y: -406, id: 'item_5', probability: 0 },
        { x: -437, y: -28, id: 'item_6', probability: 0 },
        { x: -437, y: -217, id: 'item_7', probability: 0 },
        { x: -437, y: -406, id: 'item_8', probability: 0 },
      ]
    }
    width={177}
    height={181}
    startDelay={1000}
    fixedIds={[3, 4, 7]}
    reset={this.state.reset}
    completionAnimation={true}
    onProgress={(isProgress, result) => { console.log(result); }}
  />
  <button className="start_btn" onClick={this.onClick}>{!this.state.start ? 'START' : 'STOP'}</button>
  <button className="reset_btn" onClick={this.onClickReset}>RESET</button>
</>
```

### Props

| props               | type                                                   | descripton                                                   |
| ------------------- | ------------------------------------------------------ | ------------------------------------------------------------ |
| on                  | boolean                                                | roll start status                                            |
| column              | number                                                 | number of columns to roll                                    |
| backgroundImage     | string                                                 |                                                              |
| backgroundSize      | string                                                 |                                                              |
| itemInfo            | {id?: any, x: number, y: number, probability?: number} |                                                              |
| introItemInfo       | {x: number, y: number}                                 | intro screen before rolling                                  |
| width               | number                                                 | width of one item                                            |
| height              | number                                                 | height of one item                                           |
| fixedIds            | number[] or string[]                                   | You can define the id that will be won in advance            |
| startDelay          | number                                                 | post-start delay                                             |
| reset               | boolean                                                | random initialization of all items                           |
| completionAnimation | boolean                                                | whether you want to do an animation when the item stops (IE9 is not supported) |
| rootClassName       | string                                                 | You can set className to set a custom style on the root node |
| onProgress          | (progress: boolean, result?: any[]) => void            | A callback function of the rolling animation process         |



## supported browsers

- IE9+, Chrome, Safari, Firefox, Whale, Mobile Safari, Mobile Chrome...

## Features

- Create a roller by the number you set.
- Setting items using sprite image.
- Return items as a result of matching.
- Probability can be set.
- Added delay option before rolling start.
- Intro screen can be set.
- reset option.

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