article : center game block on click, capped below menu closes #62
All checks were successful
Deploy / Deploy to Production (push) Successful in 25s
All checks were successful
Deploy / Deploy to Production (push) Successful in 25s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
58e77f9181
commit
f9dacf0eb8
1 changed files with 17 additions and 1 deletions
|
|
@ -45,7 +45,23 @@
|
||||||
iframe.style.pointerEvents = 'auto'
|
iframe.style.pointerEvents = 'auto'
|
||||||
container.classList.add('game-active')
|
container.classList.add('game-active')
|
||||||
overlay.setAttribute('data-state', 'played')
|
overlay.setAttribute('data-state', 'played')
|
||||||
container.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
||||||
|
const menuHeight = document.querySelector('header')?.offsetHeight ?? 0
|
||||||
|
const minTop = menuHeight + 16
|
||||||
|
const rect = container.getBoundingClientRect()
|
||||||
|
const centeredTop = (window.innerHeight - rect.height) / 2
|
||||||
|
const targetTop = Math.max(centeredTop, minTop)
|
||||||
|
|
||||||
|
let scrollEl = container.parentElement
|
||||||
|
while (scrollEl && scrollEl !== document.body) {
|
||||||
|
const { overflow, overflowY } = getComputedStyle(scrollEl)
|
||||||
|
if (/auto|scroll/.test(overflow + overflowY)) break
|
||||||
|
scrollEl = scrollEl.parentElement
|
||||||
|
}
|
||||||
|
const base = (!scrollEl || scrollEl === document.body) ? window.scrollY : scrollEl.scrollTop
|
||||||
|
const target = base + rect.top - targetTop
|
||||||
|
;(scrollEl && scrollEl !== document.body ? scrollEl : window)
|
||||||
|
.scrollTo({ top: target, behavior: 'smooth' })
|
||||||
})
|
})
|
||||||
|
|
||||||
deactivateBtn?.addEventListener('click', (e) => {
|
deactivateBtn?.addEventListener('click', (e) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue