From c9e2e661f0cbc736b948f8aca4c65d0467c44c79 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Wed, 16 Sep 2009 14:36:59 -0400 Subject: [PATCH] slide the title if the site changes the scroll position Slide the title away if the scroll is to zero or one, and the title is partially or fully visible. Set the animation time to at least SLIDE_TITLE_DURATION, currently set to 300 ms. --- core/java/android/webkit/WebView.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 4ca17ac73362a..abbbc00e9020e 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -420,6 +420,7 @@ public class WebView extends AbsoluteLayout private static final int STD_SPEED = 480; // pixels per second // time for the longest scroll animation private static final int MAX_DURATION = 750; // milliseconds + private static final int SLIDE_TITLE_DURATION = 300; // milliseconds private Scroller mScroller; private boolean mWrapContent; @@ -2416,10 +2417,18 @@ public class WebView extends AbsoluteLayout if ((dx | dy) == 0) { return false; } - - if (true && animate) { + // mobile sites prefer to scroll to (0, 1), thus the + 1 below + boolean slideTitle = getVisibleTitleHeight() > 0 + && y <= getTitleHeight() + 1; + if (DebugFlags.WEB_VIEW) { + Log.v(LOGTAG, "pinScrollTo slideTitle=" + slideTitle + + " getVisibleTitleHeight()=" + getVisibleTitleHeight() + + " animationDuration=" + animationDuration + " y=" + y); + } + if (slideTitle || animate) { // Log.d(LOGTAG, "startScroll: " + dx + " " + dy); - + if (slideTitle && animationDuration < SLIDE_TITLE_DURATION) + animationDuration = SLIDE_TITLE_DURATION; mScroller.startScroll(mScrollX, mScrollY, dx, dy, animationDuration > 0 ? animationDuration : computeDuration(dx, dy)); invalidate();