Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: Add hover state to thumbnails #965

Merged
merged 2 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lib/ThumbnailsSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class ThumbnailsSidebar {
thumbnailEl.className = CLASS_BOX_PREVIEW_THUMBNAIL;
thumbnailEl.dataset.bpPageNum = pageNum;
thumbnailEl.appendChild(this.createPageNumber(pageNum));

const thumbnailNav = this.createThumbnailNav();
thumbnailEl.appendChild(thumbnailNav);

Expand All @@ -233,22 +234,23 @@ class ThumbnailsSidebar {
createThumbnailNav() {
const thumbnailNav = document.createElement('a');
thumbnailNav.className = CLASS_BOX_PREVIEW_THUMBNAIL_NAV;
thumbnailNav.tabIndex = '0';
return thumbnailNav;
}

/**
* Request the thumbnail image to be made
*
* @param {number} itemIndex - the item index in the overall list (0 indexed)
* @param {HTMLElement} thumbnailEl - the thumbnail button element
* @param {HTMLElement} thumbnailEl - the thumbnail element
* @return {void}
*/
requestThumbnailImage(itemIndex, thumbnailEl) {
requestAnimationFrame(() => {
this.createThumbnailImage(itemIndex).then((imageEl) => {
// Promise will resolve with null if create image request was already in progress
if (imageEl) {
// Appends to the lastChild which should be the thumbnail nav element
// Appends to the thumbnail nav element
thumbnailEl.lastChild.appendChild(imageEl);
thumbnailEl.classList.add(CLASS_BOX_PREVIEW_THUMBNAIL_IMAGE_LOADED);
}
Expand Down
9 changes: 9 additions & 0 deletions src/lib/viewers/doc/_docBase.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,19 @@ $thumbnail-sidebar-width: 226px;
border-radius: $thumbnail-border-radius;
cursor: pointer;
flex: 1 0 154px;
outline: none;
overflow: hidden;
padding: 0;
}

.bp-thumbnail:not(.bp-thumbnail-is-selected) {
.bp-thumbnail-nav:focus,
.bp-thumbnail-nav:hover {
border: 1px solid $seesee;
margin: 2px;
}
}

.bp-thumbnail-image {
background-position: center;
background-repeat: no-repeat;
Expand Down