Skip to content

Commit

Permalink
feat: this inside time/to/delay fxns is target itself
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityataparia committed May 23, 2019
1 parent 0a7a060 commit 589ab3d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -64,7 +64,7 @@ wait(1000 /* in ms */).then(() => {
- `delay` - (in miliseconds) number or function, delay before start of animation (in ms)

If from values are not given (or object doesn't have that property), they will start from 0.
If a function for `time`, `delay`, `to` is given, it will be called with index of target to animate (starting from 0) and return value will be used as corresponding value for that target.
If a function for `time`, `delay`, `to` is given, it will be called with index of target to animate (starting from 0) and return value will be used as corresponding value for that target. `this` inside these functions is `target`.

You can add more types using bezier function values:

Expand Down
8 changes: 4 additions & 4 deletions dist/sifrr.animate.js

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

2 changes: 1 addition & 1 deletion dist/sifrr.animate.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/sifrr.animate.min.js

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

8 changes: 4 additions & 4 deletions dist/sifrr.animate.module.js

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

2 changes: 1 addition & 1 deletion dist/sifrr.animate.module.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/animate.js
Expand Up @@ -37,9 +37,9 @@ function animate({
}
let numTo = to, numDelay = delay, numTime = time;
return Promise.all(targets.map((target, i) => {
if (typeof to === 'function') numTo = to(i);
if (typeof delay === 'function') numDelay = delay(i);
if (typeof time === 'function') numTime = time(i);
if (typeof to === 'function') numTo = to.call(target, i);
if (typeof delay === 'function') numDelay = delay.call(target, i);
if (typeof time === 'function') numTime = time.call(target, i);
return iterate(target, numTo, numDelay, numTime);
}));
}
Expand Down

0 comments on commit 589ab3d

Please sign in to comment.