computes offsets (off screen overlap) of popover when trying to align it to the center
488547
function centeringProperties({ oDim, wDim, tPos, tDim }) {
  const center = Math.round(tPos + (tDim / 2));
  const leftOffset = (oDim / 2) - center;
  const rightOffset = center + (oDim / 2) - wDim;
  return { center, leftOffset, rightOffset };
}
164358
private void offsetIcon(@NonNull Rect viewBounds) {
        float startX = viewBounds.centerX() - (mPathBounds.width() / 2);
        float offsetX = startX - mPathBounds.left;

        float startY = viewBounds.centerY() - (mPathBounds.height() / 2);
        float offsetY = startY - (mPathBounds.top);

        mPath.offset(offsetX + mIconOffsetX, offsetY + mIconOffsetY);
    }
739117
function offset (ev, target) {
  var cx = ev.clientX || 0
  var cy = ev.clientY || 0
  var rect = bounds(target)
  return [ cx - rect.left, cy - rect.top ]
}
1051156
function getCenteringPrice(options) {
  const { leftOffset, rightOffset } = centeringProperties(options);
  // TODO: currently shifted popovers have higher price,
  // popover shift could be taken into account with the same price
  return Math.max(0, leftOffset) + Math.max(0, rightOffset);
}
321107
private void offsetMenu(int offsetPixels) {
        if (!mOffsetMenu || mMenuSize == 0) {
            return;
        }

        final int width = getWidth();
        final int height = getHeight();

        final int menuSize = mMenuSize;
        final int sign = (int) (mOffsetPixels / Math.abs(mOffsetPixels));
        final float openRatio = Math.abs(mOffsetPixels) / menuSize;
        final int offset = (int) (-0.25f * ((1.0f - openRatio) * menuSize) * sign);

        switch (getPosition()) {
            case LEFT: {
                if (USE_TRANSLATIONS) {
                    if (offsetPixels > 0) {
                        mMenuContainer.setTranslationX(offset);
                    } else {
                        mMenuContainer.setTranslationX(-menuSize);
                    }

                } else {
                    mMenuContainer.offsetLeftAndRight(offset - mMenuContainer.getLeft());
                    mMenuContainer.setVisibility(offsetPixels == 0 ? INVISIBLE : VISIBLE);
                }
                break;
            }

            case RIGHT: {
                if (USE_TRANSLATIONS) {
                    if (offsetPixels != 0) {
                        mMenuContainer.setTranslationX(offset);
                    } else {
                        mMenuContainer.setTranslationX(menuSize);
                    }

                } else {
                    final int oldOffset = mMenuContainer.getRight() - width;
                    final int offsetBy = offset - oldOffset;
                    mMenuContainer.offsetLeftAndRight(offsetBy);
                    mMenuContainer.setVisibility(offsetPixels == 0 ? INVISIBLE : VISIBLE);
                }
                break;
            }

            case TOP: {
                if (USE_TRANSLATIONS) {
                    if (offsetPixels > 0) {
                        mMenuContainer.setTranslationY(offset);
                    } else {
                        mMenuContainer.setTranslationY(-menuSize);
                    }

                } else {
                    mMenuContainer.offsetTopAndBottom(offset - mMenuContainer.getTop());
                    mMenuContainer.setVisibility(offsetPixels == 0 ? INVISIBLE : VISIBLE);
                }
                break;
            }

            case BOTTOM: {
                if (USE_TRANSLATIONS) {
                    if (offsetPixels != 0) {
                        mMenuContainer.setTranslationY(offset);
                    } else {
                        mMenuContainer.setTranslationY(menuSize);
                    }

                } else {
                    final int oldOffset = mMenuContainer.getBottom() - height;
                    final int offsetBy = offset - oldOffset;
                    mMenuContainer.offsetTopAndBottom(offsetBy);
                    mMenuContainer.setVisibility(offsetPixels == 0 ? INVISIBLE : VISIBLE);
                }
                break;
            }
        }

    }
1037120
function calculateOffset(element) {
      var style = window.getComputedStyle(element);
      var getCssProperty = function(prop) {
        return parseInt(style.getPropertyValue(prop).replace('px', '')) || 0;
      };
      return {
        left: element.getBoundingClientRect().left + getCssProperty('padding-left'),
        top: element.getBoundingClientRect().top + getCssProperty('padding-top')
      };
    }
134490
function calculateOffsetTop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
			curtop += obj.offsetTop
	} else if (obj.y)
		curtop += obj.y;
	return curtop;
}
153628
def get_offset
      platform = ChromedriverScreenshot::Platforms.platform
      offset_x = @x - platform.window_x
      offset_y = @y - platform.window_y
      [offset_x, offset_y]
    end
451786
function () {

            var nViewportOffset = Overlay.VIEWPORT_OFFSET,
                elementWidth = this.element.offsetWidth,
                elementHeight = this.element.offsetHeight,
                viewPortWidth = Dom.getViewportWidth(),
                viewPortHeight = Dom.getViewportHeight(),
                x,
                y;

            if (elementWidth < viewPortWidth) {
                x = (viewPortWidth / 2) - (elementWidth / 2) + Dom.getDocumentScrollLeft();
            } else {
                x = nViewportOffset + Dom.getDocumentScrollLeft();
            }

            if (elementHeight < viewPortHeight) {
                y = (viewPortHeight / 2) - (elementHeight / 2) + Dom.getDocumentScrollTop();
            } else {
                y = nViewportOffset + Dom.getDocumentScrollTop();
            }

            this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
            this.cfg.refireEvent("iframe");

            if (UA.webkit) {
                this.forceContainerRedraw();
            }
        }
680802
void adjustOffsets(final double pNorthOrWest, final double pSouthOrEast,
					   final boolean isLatitude, final int pExtraSize) {
		final long min;
		final long max;
		final long deltaX;
		final long deltaY;
		if (isLatitude) {
			min = getLongPixelYFromLatitude(pNorthOrWest);
			max = getLongPixelYFromLatitude(pSouthOrEast);
			deltaX = 0;
			deltaY = getScrollableOffset(min, max, mMercatorMapSize, mIntrinsicScreenRectProjection.height(), pExtraSize);
		} else {
			min = getLongPixelXFromLongitude(pNorthOrWest);
			max = getLongPixelXFromLongitude(pSouthOrEast);
			deltaX = getScrollableOffset(min, max, mMercatorMapSize, mIntrinsicScreenRectProjection.width(), pExtraSize);
			deltaY = 0;
		}
		adjustOffsets(deltaX, deltaY);
	}
582895
function (oThis) {
                var sParam = "sapUiUx3ToolPopupArrowWidth";
                oThis.sArrowWidth = Parameters.get(sParam);
                oThis.iArrowWidth = parseInt(oThis.sArrowWidth);

                sParam = "sapUiUx3ToolPopupArrowHeight";
                oThis.sArrowHeight = Parameters.get(sParam);
                oThis.iArrowHeight = parseInt(oThis.sArrowHeight);

                sParam = "sapUiUx3ToolPopupArrowRightMarginCorrection";
                oThis.sArrowPadding = Parameters.get(sParam);
                oThis.iArrowPadding = parseInt(oThis.sArrowPadding);

                sParam = "sapUiUx3ToolPopupArrowRightMarginCorrectionInverted";
                oThis.sArrowPaddingInverted = Parameters.get(sParam);
                oThis.iArrowPaddingInverted = parseInt(oThis.sArrowPaddingInverted);
            }
1125892
def get_center_offset(self):
        
        return (-self.view_rect.centerx + self._half_width,
                -self.view_rect.centery + self._half_height)
493891
function getOffset() {
            if (isElem) {

                var win = window;
                var docElem = document.documentElement;
                var box = anchor.getBoundingClientRect();

                return {
                    top: box.top + win.pageYOffset - docElem.clientTop,
                    left: box.left + win.pageXOffset - docElem.clientLeft
                };
            } else {
                return {
                    left: anchor.pageX,
                    top: anchor.pageY
                };
            }
        }
1025047
function offset(element) {
	const elemBCR = element.getBoundingClientRect();
	return {
		width: Math.round(isNumber(elemBCR.width) ? elemBCR.width : element.offsetWidth),
		height: Math.round(isNumber(elemBCR.height) ? elemBCR.height : element.offsetHeight),
		top: Math.round(elemBCR.top + (window.pageYOffset || document.documentElement.scrollTop)),
		left: Math.round(elemBCR.left + (window.pageXOffset || document.documentElement.scrollLeft))
	};
}
169983
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	private void offsetMenu(int offsetPixels) {
		 if (!mOffsetMenu || mSwipeBackViewSize == 0) {
			 return;
		 }

		 final int width = getWidth();
		 final int height = getHeight();

		 final int menuSize = mSwipeBackViewSize;
		 final int sign = (int) (mOffsetPixels / Math.abs(mOffsetPixels));
		 final float openRatio = Math.abs(mOffsetPixels) / menuSize;
		 final int offset = (int) (-0.25f * ((1.0f - openRatio) * menuSize) * sign);

		 switch (getPosition()) {
		 case LEFT: {
			 if (USE_TRANSLATIONS) {
				 if (offsetPixels > 0) {
					mSwipeBackContainer.setTranslationX(offset);
				 } else {
					mSwipeBackContainer.setTranslationX(-menuSize);
				 }

			 } else {
				mSwipeBackContainer.offsetLeftAndRight(offset
						- mSwipeBackContainer.getLeft());
				mSwipeBackContainer.setVisibility(offsetPixels == 0 ? INVISIBLE
						: VISIBLE);
			 }
			 break;
		 }

		 case RIGHT: {
			 if (USE_TRANSLATIONS) {
				 if (offsetPixels != 0) {
					mSwipeBackContainer.setTranslationX(offset);
				 } else {
					mSwipeBackContainer.setTranslationX(menuSize);
				 }

			 } else {
				final int oldOffset = mSwipeBackContainer.getRight() - width;
				 final int offsetBy = offset - oldOffset;
				mSwipeBackContainer.offsetLeftAndRight(offsetBy);
				mSwipeBackContainer.setVisibility(offsetPixels == 0 ? INVISIBLE
						: VISIBLE);
			 }
			 break;
		 }

		 case TOP: {
			 if (USE_TRANSLATIONS) {
				 if (offsetPixels > 0) {
					mSwipeBackContainer.setTranslationY(offset);
				 } else {
					mSwipeBackContainer.setTranslationY(-menuSize);
				 }

			 } else {
				mSwipeBackContainer.offsetTopAndBottom(offset
						- mSwipeBackContainer.getTop());
				mSwipeBackContainer.setVisibility(offsetPixels == 0 ? INVISIBLE
						: VISIBLE);
			 }
			 break;
		 }

		 case BOTTOM: {
			 if (USE_TRANSLATIONS) {
				 if (offsetPixels != 0) {
					mSwipeBackContainer.setTranslationY(offset);
				 } else {
					mSwipeBackContainer.setTranslationY(menuSize);
				 }

			 } else {
				final int oldOffset = mSwipeBackContainer.getBottom() - height;
				 final int offsetBy = offset - oldOffset;
				mSwipeBackContainer.offsetTopAndBottom(offsetBy);
				mSwipeBackContainer.setVisibility(offsetPixels == 0 ? INVISIBLE
						: VISIBLE);
			 }
			 break;
		 }
		 }

	 }
836355
function getOffsetParent(node) {
		var offsetParent = node.parentNode, documentElement = document.documentElement;
		while (offsetParent && offsetParent !== documentElement) {
			var style = window.getComputedStyle(offsetParent, null);
			if (!style) { break; }
			var overflow = style.getPropertyValue("overflow-y"); //$NON-NLS-0$
			if (overflow === "auto" || overflow === "scroll") { break; } //$NON-NLS-1$ //$NON-NLS-0$
			offsetParent = offsetParent.parentNode;
		}
		return offsetParent;
	}
1300817
function(e) {
      var t = this,
          box = t.getComponentArea(),
          sidebarWidth = t.sidebar.width(),
          canvasWidth = t.$el.width() - sidebarWidth,
          canvasCenter = canvasWidth / 2;

      // No components
      if (!box.width) {return;}

      // Obtain the center point, and offset the canvas by the difference
      // Keep the left margin at multiples of 10 to match components
      var componentCenter = box.left + (box.width / 2);
      var newLeft = sidebarWidth + Math.max(0, canvasCenter - componentCenter);
      newLeft = newLeft - newLeft % 10;
      t.canvas.css({marginLeft: newLeft});
    }