Compare commits
2 commits
618c8d79c4
...
f9dacf0eb8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9dacf0eb8 | ||
|
|
58e77f9181 |
6 changed files with 20 additions and 4 deletions
|
|
@ -70,8 +70,8 @@ tabs:
|
|||
extends: blocks/image
|
||||
video:
|
||||
extends: blocks/video
|
||||
jeu:
|
||||
extends: blocks/jeu
|
||||
game:
|
||||
extends: blocks/game
|
||||
white-paper:
|
||||
extends: blocks/white-paper
|
||||
|
||||
|
|
|
|||
|
|
@ -17,5 +17,5 @@
|
|||
@import "./blocks/list.css";
|
||||
@import "./blocks/quote.css";
|
||||
@import "./blocks/image.css";
|
||||
@import "./blocks/jeu.css";
|
||||
@import "./blocks/game.css";
|
||||
@import "./blocks/white-paper.css";
|
||||
|
|
|
|||
|
|
@ -45,7 +45,23 @@
|
|||
iframe.style.pointerEvents = 'auto'
|
||||
container.classList.add('game-active')
|
||||
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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue