Skip to content

Commit

Permalink
Support some new countup features (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarkelov authored Oct 31, 2023
1 parent 81e5f61 commit 151682b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Click [here](https://codesandbox.io/s/github/glennreyes/react-countup/tree/maste
- [`preserveValue: boolean`](#preservevalue-boolean)
- [`separator: string`](#separator-string)
- [`start: number`](#start-number)
- [`plugin: CountUpPlugin`](#plugin-countupplugin)
- [`startOnMount: boolean`](#startonmount-boolean)
- [`suffix: string`](#suffix-string)
- [`useEasing: boolean`](#useeasing-boolean)
Expand Down Expand Up @@ -265,6 +266,10 @@ Initial value.

Default: `0`

#### `plugin: CountUpPlugin`

Define plugin for alternate animations

#### `startOnMount: boolean`

Use for start counter on mount for hook usage.
Expand Down Expand Up @@ -461,6 +466,29 @@ export default function App() {
}
```

### Plugin usage

```js
import { CountUp } from 'countup.js';
import { Odometer } from 'odometer_countup';

export default function App() {
useCountUp({
ref: 'counter',
end: 1234567,
enableScrollSpy: true,
scrollSpyDelay: 1000,
plugin: Odometer,
});

return (
<div className="App">
<span id="counter" />
</div>
);
}
```

## License

MIT
2 changes: 2 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const createCountUpInstance = (
enableScrollSpy,
scrollSpyDelay,
scrollSpyOnce,
plugin,
} = props;

return new CountUp(el, end, {
Expand All @@ -36,6 +37,7 @@ export const createCountUpInstance = (
separator,
prefix,
suffix,
plugin,
useEasing,
useIndianSeparators,
useGrouping,
Expand Down

0 comments on commit 151682b

Please sign in to comment.