Skip to content

Exposes previous X and previous Y in callback#43

Open
romellem wants to merge 4 commits intochrisbateman:masterfrom
romellem:master
Open

Exposes previous X and previous Y in callback#43
romellem wants to merge 4 commits intochrisbateman:masterfrom
romellem:master

Conversation

@romellem
Copy link
Copy Markdown

@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