jgwhite/ember-sortable

View on GitHub
addon/utils/coordinate.js

Summary

Maintainability
A
2 hrs
Test Coverage
/**
  Gets the y offset for a given event.
  Work for touch and mouse events.
  @method getY
  @return {Number}
  @private
*/
export function getY(event) {
  let touches = event.changedTouches;
  let touch = touches && touches[0];

  if (touch) {
    return touch.screenY;
  } else {
    return event.clientY;
  }
}

/**
  Gets the x offset for a given event.
  @method getX
  @return {Number}
  @private
*/
export function getX(event) {
  let touches = event.changedTouches;
  let touch = touches && touches[0];

  if (touch) {
    return touch.screenX;
  } else {
    return event.clientX;
  }
}