Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support some new countup features #821

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading