Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetHeaderViewHolder.java | 
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetHeaderViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetHeaderViewHolder.java | 
| index 28ec164bb7f56cc8b4abbc45f595964659421568..a9d0f3263db8f207cdf6ccad99c51763b1f6a0cd 100644 | 
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetHeaderViewHolder.java | 
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetHeaderViewHolder.java | 
| @@ -50,6 +50,18 @@ public class SnippetHeaderViewHolder extends NewTabPageViewHolder { | 
| } | 
| /** | 
| + * Only allow the header to transition if the user has not scrolled on the page beyond the | 
| + * |mMaxPeekPadding + mMaxSnippetHeaderHeight|. There will only ever be one peeking card on the | 
| + * page and only when there is enough space to show the peeking card on the first screen at the | 
| + * bottom. | 
| + * @return | 
| 
 
Michael van Ouwerkerk
2016/07/15 15:05:28
Also same as for the other one: either document @r
 
mcwilliams
2016/07/18 15:11:45
Done.
 
 | 
| + */ | 
| + private boolean allowHeaderToTransition() { | 
| 
 
Michael van Ouwerkerk
2016/07/15 15:05:28
Same as for the other method, I think "isHeaderAll
 
PEConn
2016/07/15 15:08:23
(again, maybe isHeaderTransitionAllowed instead)
 
mcwilliams
2016/07/18 15:11:45
Done.
 
 | 
| + return mRecyclerView.computeVerticalScrollOffset() | 
| + <= mMaxSnippetHeaderHeight + mMaxPeekPadding; | 
| + } | 
| + | 
| + /** | 
| * Update the view for the fade in/out and heading height. | 
| */ | 
| public void updateDisplay() { | 
| @@ -58,11 +70,15 @@ public class SnippetHeaderViewHolder extends NewTabPageViewHolder { | 
| int snippetHeaderTop = itemView.getTop(); | 
| int recyclerViewHeight = mRecyclerView.getHeight(); | 
| - // Check if snippet header top is within range to start showing. Set the header height, this | 
| - // is a percentage of how much is scrolled. The balance of the scroll will | 
| - // be used to display the peeking card. | 
| - int amountScrolled = (recyclerViewHeight - mMaxPeekPadding) - snippetHeaderTop; | 
| - if (mHeader.isVisible()) { | 
| + if (!mHeader.isVisible()) { | 
| + headerHeight = 0; | 
| + } else if (!allowHeaderToTransition()) { | 
| + headerHeight = mMaxSnippetHeaderHeight; | 
| + } else { | 
| + // Check if snippet header top is within range to start showing. Set the header height, | 
| + // this is a percentage of how much is scrolled. The balance of the scroll will be used | 
| + // to display the peeking card. | 
| + int amountScrolled = (recyclerViewHeight - mMaxPeekPadding) - snippetHeaderTop; | 
| headerHeight = MathUtils.clamp((int) (amountScrolled * SCROLL_HEADER_HEIGHT_PERCENTAGE), | 
| 0, mMaxSnippetHeaderHeight); | 
| } |