is-primary-pointer.mjs 616 B

123456789101112131415161718
  1. const isPrimaryPointer = (event) => {
  2. if (event.pointerType === "mouse") {
  3. return typeof event.button !== "number" || event.button <= 0;
  4. }
  5. else {
  6. /**
  7. * isPrimary is true for all mice buttons, whereas every touch point
  8. * is regarded as its own input. So subsequent concurrent touch points
  9. * will be false.
  10. *
  11. * Specifically match against false here as incomplete versions of
  12. * PointerEvents in very old browser might have it set as undefined.
  13. */
  14. return event.isPrimary !== false;
  15. }
  16. };
  17. export { isPrimaryPointer };