Commit a3f20a62 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

PDF Viewer Update: Thumbnail scrolling polishes

1) Use a new method focusAndScroll() on thumbnails that disables the
default scrolling behavior of focus() and uses scrollIntoView() instead.
That way the scrolling behavior of focused and active thumbnails are
unified.

2) Add a top padding to the first thumbnail so the box shadow is shown
when the thumbnail is scrolled into view.

3) Remove the opacity transition on thumbnails, which was causing some
flashing to occur while scrolling through the active thumbnail quickly
using the keyboard.

Bug: 652400
Change-Id: Ie8b26c670b03b4829444215d184e54e39f344924
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2441936Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812581}
parent 3062e1be
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
box-sizing: border-box; box-sizing: border-box;
height: 100%; height: 100%;
overflow: auto; overflow: auto;
padding: 24px 0; padding-bottom: 24px;
padding-inline-end: var(--viewer-thumbnail-bar-padding-inline-end); padding-inline-end: var(--viewer-thumbnail-bar-padding-inline-end);
text-align: center; text-align: center;
} }
viewer-thumbnail + viewer-thumbnail { viewer-thumbnail {
padding-top: 24px; padding-top: 24px;
} }
</style> </style>
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
canvas { canvas {
display: block; display: block;
opacity: 0.5; opacity: 0.5;
transition: opacity 100ms ease-out;
} }
:host([is-active]) canvas { :host([is-active]) canvas {
......
...@@ -104,6 +104,17 @@ export class ViewerThumbnailElement extends PolymerElement { ...@@ -104,6 +104,17 @@ export class ViewerThumbnailElement extends PolymerElement {
return {width: cssWidth, height: cssHeight}; return {width: cssWidth, height: cssHeight};
} }
/**
* Focuses and scrolls the element into view.
* The default scroll behavior of focus() acts differently than
* scrollIntoView(), which is called in isActiveChanged_(). This method
* unifies the behavior.
*/
focusAndScroll() {
this.scrollIntoView({block: 'nearest'});
this.focus({preventScroll: true});
}
/** @return {boolean} */ /** @return {boolean} */
isPending() { isPending() {
return this.hasAttribute('pending'); return this.hasAttribute('pending');
...@@ -122,15 +133,17 @@ export class ViewerThumbnailElement extends PolymerElement { ...@@ -122,15 +133,17 @@ export class ViewerThumbnailElement extends PolymerElement {
/** @private */ /** @private */
focusThumbnailNext_() { focusThumbnailNext_() {
if (this.nextElementSibling) { if (this.nextElementSibling &&
this.nextElementSibling.focus(); this.nextElementSibling.matches('viewer-thumbnail')) {
this.nextElementSibling.focusAndScroll();
} }
} }
/** @private */ /** @private */
focusThumbnailPrev_() { focusThumbnailPrev_() {
if (this.previousElementSibling) { if (this.previousElementSibling &&
this.previousElementSibling.focus(); this.previousElementSibling.matches('viewer-thumbnail')) {
this.previousElementSibling.focusAndScroll();
} }
} }
......
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