impetus icon indicating copy to clipboard operation
impetus copied to clipboard

Exposes previous X and previous Y in callback

Open romellem opened this issue 7 years ago • 0 comments

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.

romellem avatar Oct 09 '18 23:10 romellem