Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

BUG: apply instead of drag callbacks #120

Open
Phoscur opened this issue Mar 28, 2014 · 1 comment
Open

BUG: apply instead of drag callbacks #120

Phoscur opened this issue Mar 28, 2014 · 1 comment

Comments

@Phoscur
Copy link

Phoscur commented Mar 28, 2014

Updating this library breaks my code:

ft = this.freetransform(surface, opts, function(ft, events) {
  if (events.indexOf("drag") !== -1) {
     set.transform(..) // wont be called any more
});

Inspecting this, only "init", "apply" and "drag end" events are fired.
Reverting to older freeTransform revision.

@jwarren1980
Copy link

There is a bug in the current code that causes some events to not be sent to your callback function all the time.

The solution I used, which works for handling all events as they are called, in order, is to replace the function asyncCallback with the one below:

/**
 * Call callback asynchronously for better performance
 */
function asyncCallback(e)
{
     if (ft.callback)
     {
          // Remove empty values
          var events = [];

          e.map(function (e, i) { if (e) { events.push(e); } });

          //clearTimeout(timeout);

          //timeout = setTimeout(function () { if (ft.callback) { ft.callback(ft, events); } }, 1);

          if (ft.callback) { ft.callback(ft, events); }
     }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants