Skip to content

Commit

Permalink
Update: Add hover state to thumbnails (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Chan authored Mar 26, 2019
1 parent 6f2200a commit 096b183
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit 096b183

Please sign in to comment.