Skip to content

Commit

Permalink
Merge pull request #16 from internetarchive/webdev-6544-ff-volume-scr…
Browse files Browse the repository at this point in the history
…oll-fix

Applied fix for FF and other browsers to auto-scroll to active volume
  • Loading branch information
nsharma123 authored Jan 18, 2024
2 parents 2c5e311 + cb759bc commit c970600
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@internetarchive/ia-item-navigator",
"version": "2.1.0",
"version": "2.1.1",
"description": "Internet Archive's Item Navigator, visually explore an item's contents.",
"repository": {
"type": "git",
Expand Down
20 changes: 14 additions & 6 deletions src/menus/viewable-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,20 @@ export class IauxViewableFiles extends LitElement {
// allow for css animations to run before scrolling to active file
setTimeout(() => {
// scroll active file into view if needed
// note: `scrollIntoViewIfNeeded` handles auto-scroll gracefully for Chrome, Safari
// Firefox does not have this capability yet as it does not support `scrollIntoViewIfNeeded`
activeFile?.scrollIntoViewIfNeeded(true);

// Todo: support `scrollIntoView` or `parentContainer.crollTop = x` for FF & "IE 11"
// currently, the hard `position: absolutes` misaligns subpanel when `scrollIntoView` is applied :(
// note:
// - `scrollIntoViewIfNeeded` handles auto-scroll gracefully for Chrome, Safari
// - `scrollIntoView` handles auto-scroll for almost all the browsers. specifially FF.
if (activeFile?.scrollIntoViewIfNeeded) {
// `scrollIntoViewIfNeeded` auto-scroll only if element not is visible area
activeFile?.scrollIntoViewIfNeeded(true);
} else {
// `scrollIntoView` always auto-scroll to center of visible area
activeFile?.scrollIntoView({
behavior: 'smooth',
block: 'nearest',
inline: 'nearest',
});
}
}, 350);
}

Expand Down

0 comments on commit c970600

Please sign in to comment.