diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index f2c5d93..2e19f6e 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -959,32 +959,22 @@
         int centerY = (int) (sTempRect.top + sTempRect.height() * scale / 2);
         int centeredLeft = centerX - width / 2;
         int centeredTop = centerY - height / 2;
-        int currentPage = mLauncher.getWorkspace().getNextPage();
-        // In case the workspace is scrolling, we need to use the final scroll to compute
-        // the folders bounds.
-        mLauncher.getWorkspace().setFinalScrollForPageChange(currentPage);
-        // We first fetch the currently visible CellLayoutChildren
-        CellLayout currentLayout = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPage);
-        ShortcutAndWidgetContainer boundingLayout = currentLayout.getShortcutsAndWidgets();
-        Rect bounds = new Rect();
-        parent.getDescendantRectRelativeToSelf(boundingLayout, bounds);
-        // We reset the workspaces scroll
-        mLauncher.getWorkspace().resetFinalScrollForPageChange(currentPage);
 
-        // We need to bound the folder to the currently visible CellLayoutChildren
-        int left = Math.min(Math.max(bounds.left, centeredLeft),
-                bounds.left + bounds.width() - width);
-        int top = Math.min(Math.max(bounds.top, centeredTop),
-                bounds.top + bounds.height() - height);
+        // We need to bound the folder to the currently visible workspace area
+        mLauncher.getWorkspace().getPageAreaRelativeToDragLayer(sTempRect);
+        int left = Math.min(Math.max(sTempRect.left, centeredLeft),
+                sTempRect.left + sTempRect.width() - width);
+        int top = Math.min(Math.max(sTempRect.top, centeredTop),
+                sTempRect.top + sTempRect.height() - height);
         if (grid.isPhone && (grid.availableWidthPx - width) < grid.iconSizePx) {
             // Center the folder if it is full (on phones only)
             left = (grid.availableWidthPx - width) / 2;
-        } else if (width >= bounds.width()) {
+        } else if (width >= sTempRect.width()) {
             // If the folder doesn't fit within the bounds, center it about the desired bounds
-            left = bounds.left + (bounds.width() - width) / 2;
+            left = sTempRect.left + (sTempRect.width() - width) / 2;
         }
-        if (height >= bounds.height()) {
-            top = bounds.top + (bounds.height() - height) / 2;
+        if (height >= sTempRect.height()) {
+            top = sTempRect.top + (sTempRect.height() - height) / 2;
         }
 
         int folderPivotX = width / 2 + (centeredLeft - left);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 451f124..4a6b90a 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -28,7 +28,6 @@
 import android.appwidget.AppWidgetProviderInfo;
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
@@ -248,11 +247,6 @@
     private SparseArray<Parcelable> mSavedStates;
     private final ArrayList<Integer> mRestoredPages = new ArrayList<Integer>();
 
-    // These variables are used for storing the initial and final values during workspace animations
-    private int mSavedScrollX;
-    private float mSavedRotationY;
-    private float mSavedTranslationX;
-
     private float mCurrentScale;
     private float mTransitionProgress;
 
@@ -2762,26 +2756,26 @@
         }
     }
 
-    public void setFinalScrollForPageChange(int pageIndex) {
-        CellLayout cl = (CellLayout) getChildAt(pageIndex);
-        if (cl != null) {
-            mSavedScrollX = getScrollX();
-            mSavedTranslationX = cl.getTranslationX();
-            mSavedRotationY = cl.getRotationY();
-            final int newX = getScrollForPage(pageIndex);
-            setScrollX(newX);
-            cl.setTranslationX(0f);
-            cl.setRotationY(0f);
+    /**
+     * Computes the area relative to dragLayer which is used to display a page.
+     */
+    public void getPageAreaRelativeToDragLayer(Rect outArea) {
+        CellLayout child = (CellLayout) getChildAt(getNextPage());
+        if (child == null) {
+            return;
         }
-    }
+        ShortcutAndWidgetContainer boundingLayout = child.getShortcutsAndWidgets();
 
-    public void resetFinalScrollForPageChange(int pageIndex) {
-        if (pageIndex >= 0) {
-            CellLayout cl = (CellLayout) getChildAt(pageIndex);
-            setScrollX(mSavedScrollX);
-            cl.setTranslationX(mSavedTranslationX);
-            cl.setRotationY(mSavedRotationY);
-        }
+        // Use the absolute left instead of the child left, as we want the visible area
+        // irrespective of the visible child. Since the view can only scroll horizontally, the
+        // top position is not affected.
+        mTempXY[0] = getViewportOffsetX() + getPaddingLeft() + boundingLayout.getLeft();
+        mTempXY[1] = child.getTop() + boundingLayout.getTop();
+
+        float scale = mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY);
+        outArea.set(mTempXY[0], mTempXY[1],
+                (int) (mTempXY[0] + scale * boundingLayout.getMeasuredWidth()),
+                (int) (mTempXY[1] + scale * boundingLayout.getMeasuredHeight()));
     }
 
     public void getViewLocationRelativeToSelf(View v, int[] location) {
