Commit c68e2320 authored by peconn's avatar peconn Committed by Commit bot

[NewTabPage] Refine fakebox scrolling transition on tablets.

- Add the tab strip height factor into the transition equation to make sure the
transition is anchored to the top of the tab.
- Override ntp_search_box_transition_length to make the transition take longer
on tablets.

BUG=625145

Review-Url: https://codereview.chromium.org/2345673002
Cr-Commit-Position: refs/heads/master@{#419137}
parent d6789a38
......@@ -34,6 +34,7 @@
<!-- NTP dimensions -->
<dimen name="ntp_logo_height">180dp</dimen>
<dimen name="ntp_search_box_transition_length">60dp</dimen>
<!-- Recent tabs page -->
<dimen name="recent_tabs_visible_separator_padding">28dp</dimen>
......
......@@ -490,10 +490,13 @@ public class NewTabPageView extends FrameLayout
final int scrollY = getVerticalScroll();
final float transitionLength =
getResources().getDimension(R.dimen.ntp_search_box_transition_length);
// Tab strip height is zero on phones, nonzero on tablets.
int tabStripHeight = getResources().getDimensionPixelSize(R.dimen.tab_strip_height);
// |scrollY - searchBoxTop| gives the distance the search bar is from the top of the screen.
return MathUtils.clamp(
(scrollY - searchBoxTop + transitionLength) / transitionLength, 0f, 1f);
// |scrollY - searchBoxTop + tabStripHeight| gives the distance the search bar is from the
// top of the tab.
return MathUtils.clamp((scrollY - searchBoxTop + transitionLength + tabStripHeight)
/ transitionLength, 0f, 1f);
}
private ViewGroup getWrapperView() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment