Skip to content

Commit e580fc2

Browse files
authored
feat: add a fallback method on start (#321)
* feat: add a fallback method on start * docs: add onStartCallback doc * bundle: build js
1 parent 63d238f commit e580fc2

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ interface CountUpOptions {
6969
scrollSpyDelay?: number; // delay (ms) after target comes into view
7070
scrollSpyOnce?: boolean; // run only once
7171
onCompleteCallback?: () => any; // gets called when animation completes
72+
onStartCallback?: () => any; // gets called when animation start
7273
plugin?: CountUpPlugin; // for alternate animations
7374
}
7475
```
@@ -89,7 +90,13 @@ Pass options:
8990
const countUp = new CountUp('targetId', 5234, options);
9091
```
9192

92-
with optional callback:
93+
with optional start callback:
94+
95+
```js
96+
const countUp = new CountUp('targetId', 5234, { onStartCallback: someMethod });
97+
```
98+
99+
with optional complete callback:
93100

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

dist/countUp.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface CountUpOptions {
1818
scrollSpyDelay?: number;
1919
scrollSpyOnce?: boolean;
2020
onCompleteCallback?: () => any;
21+
onStartCallback?: () => any;
2122
plugin?: CountUpPlugin;
2223
}
2324
export declare interface CountUpPlugin {

dist/countUp.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ var CountUp = /** @class */ (function () {
206206
if (this.error) {
207207
return;
208208
}
209+
if (this.options.onStartCallback) {
210+
this.options.onStartCallback();
211+
}
209212
if (callback) {
210213
this.options.onCompleteCallback = callback;
211214
}

dist/countUp.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)