Skip to content

Exposes previous X and previous Y in callback #10

Merged
romellem merged 2 commits intomasterfrom
feature/expose-previous-x-y
Mar 29, 2020
Merged

Exposes previous X and previous Y in callback #10
romellem merged 2 commits intomasterfrom
feature/expose-previous-x-y

Conversation

@romellem
Copy link
Copy Markdown
Owner

Same change as chrisbateman/impetus#43

In my case, I didn't just want absolute X and Y values, but wanted to see how those X and Y values had changed since the last callback.

By exposing the previous X and Y values in our callback via two new arguments, I can now calculate these deltas. For example:

new Impetus({
    source: '#some-element',
    update: function(x, y, px, py) {
        console.log('x ', x);
        console.log('y ', y);
        console.log('previous x ', px);
        console.log('previous y ', py);
        console.log('change in x ', x - px);
        console.log('change in y ', y - py);
    }
});

No need to add the extra function call each time.
@romellem romellem merged commit 201c5a9 into master Mar 29, 2020
@romellem romellem deleted the feature/expose-previous-x-y branch March 29, 2020 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant