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;
            }
        }

    }
Offsets the menu relative to its original position based on the position of the content.

@param offsetPixels The number of pixels the content if offset.
menudrawer/src/net/simonvt/menudrawer/SlidingDrawer.java