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

Exposes previous X and previous Y in callback #43

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

romellem
Copy link

@romellem romellem commented Oct 9, 2018

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);
    }
});

I've also included the commits from #41 (Fix memory leaks) since those proved to be a fairly useful addition to the codebase.

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