Skip to content

Commit

Permalink
center clicked tab to a fourth of viewport height
Browse files Browse the repository at this point in the history
  • Loading branch information
stefano-ottolenghi committed Jul 23, 2024
1 parent 6fdbe90 commit ba89a75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/js/06-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,14 @@ document.addEventListener('DOMContentLoaded', function () {
}
var offset = document.querySelector('.navbar').offsetHeight + toolbarOffset + 20

var vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
var bodyRect = document.body.getBoundingClientRect().top
var elementRect = tab.getBoundingClientRect().top
var elementPosition = elementRect - bodyRect
var offsetPosition = elementPosition - offset
var offsetPosition = elementPosition - offset - vh / 4

window.scrollTo({
top: offsetPosition,
behavior: 'smooth',
top: offsetPosition, // center clicked tab to a fourth of viewport height

Check failure on line 301 in src/js/06-code.js

View workflow job for this annotation

GitHub Actions / build

Multiple spaces found before '// center clic...'
})
}

Expand Down
6 changes: 3 additions & 3 deletions src/js/08-tabs-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ document.addEventListener('DOMContentLoaded', function () {
}
var offset = document.querySelector('.navbar').offsetHeight + toolbarOffset + 20

var vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
var bodyRect = document.body.getBoundingClientRect().top
var elementRect = tab.getBoundingClientRect().top
var elementPosition = elementRect - bodyRect
var offsetPosition = elementPosition - offset
var offsetPosition = elementPosition - offset - vh / 4

window.scrollTo({
top: offsetPosition,
behavior: 'smooth',
top: offsetPosition, // center clicked tab to a fourth of viewport height

Check failure on line 80 in src/js/08-tabs-block.js

View workflow job for this annotation

GitHub Actions / build

Multiple spaces found before '// center clic...'
})

if (sessionStorageAvailable) {
Expand Down

0 comments on commit ba89a75

Please sign in to comment.