Skip to content

Commit

Permalink
feat: add a fallback method on start (#321)
Browse files Browse the repository at this point in the history
* feat: add a fallback method on start

* docs: add onStartCallback doc

* bundle: build js
  • Loading branch information
cherrol committed Aug 25, 2023
1 parent 63d238f commit e580fc2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ interface CountUpOptions {
scrollSpyDelay?: number; // delay (ms) after target comes into view
scrollSpyOnce?: boolean; // run only once
onCompleteCallback?: () => any; // gets called when animation completes
onStartCallback?: () => any; // gets called when animation start
plugin?: CountUpPlugin; // for alternate animations
}
```
Expand All @@ -89,7 +90,13 @@ Pass options:
const countUp = new CountUp('targetId', 5234, options);
```

with optional callback:
with optional start callback:

```js
const countUp = new CountUp('targetId', 5234, { onStartCallback: someMethod });
```

with optional complete callback:

```js
const countUp = new CountUp('targetId', 5234, { onCompleteCallback: someMethod });
Expand Down
1 change: 1 addition & 0 deletions dist/countUp.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface CountUpOptions {
scrollSpyDelay?: number;
scrollSpyOnce?: boolean;
onCompleteCallback?: () => any;
onStartCallback?: () => any;
plugin?: CountUpPlugin;
}
export declare interface CountUpPlugin {
Expand Down
3 changes: 3 additions & 0 deletions dist/countUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ var CountUp = /** @class */ (function () {
if (this.error) {
return;
}
if (this.options.onStartCallback) {
this.options.onStartCallback();
}
if (callback) {
this.options.onCompleteCallback = callback;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/countUp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e580fc2

Please sign in to comment.