lib/features/grid-snapping/GridSnapping.js
function getSnapOffset(event, axis) {
  var context = event.context,
      shape = event.shape,
      gridSnappingContext = context.gridSnappingContext || {},
      snapLocation = gridSnappingContext.snapLocation;

  if (!shape || !snapLocation) {
    return 0;
  }

  if (axis === 'x') {
    if (/left/.test(snapLocation)) {
      return -shape.width / 2;
    }

    if (/right/.test(snapLocation)) {
      return shape.width / 2;
    }
  } else {
    if (/top/.test(snapLocation)) {
      return -shape.height / 2;
    }

    if (/bottom/.test(snapLocation)) {
      return shape.height / 2;
    }
  }

  return 0;
}
function getSnapOffset(event, axis) {
  var context = event.context,
      shape = event.shape,
      gridSnappingContext = context.gridSnappingContext || {},
      snapLocation = gridSnappingContext.snapLocation;

  if (!shape || !snapLocation) {
    return 0;
  }

  if (axis === 'x') {
    if (/left/.test(snapLocation)) {
      return -shape.width / 2;
    }

    if (/right/.test(snapLocation)) {
      return shape.width / 2;
    }
  } else {
    if (/top/.test(snapLocation)) {
      return -shape.height / 2;
    }

    if (/bottom/.test(snapLocation)) {
      return shape.height / 2;
    }
  }

  return 0;
}
function getSnapOffset ( event , axis ) { var context = event . context , shape = event . shape , gridSnappingContext = context . gridSnappingContext || { } , snapLocation = gridSnappingContext . snapLocation ; if ( ! shape || ! snapLocation ) { return 0 ; } if ( axis === 'x' ) { if ( / left / . test ( snapLocation ) ) { return - shape . width / 2 ; } if ( / right / . test ( snapLocation ) ) { return shape . width / 2 ; } } else { if ( / top / . test ( snapLocation ) ) { return - shape . height / 2 ; } if ( / bottom / . test ( snapLocation ) ) { return shape . height / 2 ; } } return 0 ; }
Get snap offset assuming that event is at center of shape.

@param {Object} event
@param {string} axis

@returns {number}
Get snap offset assuming that event is at center of shape .