zingtouch icon indicating copy to clipboard operation
zingtouch copied to clipboard

Docs don't explain how to listen to pan end when using custom Pan instance

Open hackhat opened this issue 5 years ago • 2 comments

  const zingPan = new ZingTouch.Pan({
    numInputs: 1,
    threshold: 1,
  });
  zingTouchActiveRegion.bind(this.canvasElement, zingPan, (e) => {
  });

What should I do to get the pan end event?

hackhat avatar Aug 23 '18 08:08 hackhat

IIRC, something like this should work:

const zingPan = new ZingTouch.Pan({
  numInputs: 1,
  threshold: 1,
});
const panEnd = zingPan.end; // save the default pan end function.
zingPan.end = function customEnd(inputs, state, element) {
  // ... stuff you want done before the default end.
  panEnd(inputs, state, element);
  // ... stuff you want done after the default end.
};
ZingTouchActiveRegion.bind(this.canvasElement, zingPan, (e) => {
});

It's a little less than elegant, but it works well and makes things easy to customize, although you do have to poke around in the source code.

mvanderkamp avatar Aug 23 '18 17:08 mvanderkamp

Yeah, the api looks pretty bad. I wonder if is buggy on mobile. I'm coming from hammerjs and sometimes it misses some pan/pinch events and is pretty annoying. Happens the same with this library? or any known annoying bugs?

hackhat avatar Aug 24 '18 06:08 hackhat