2 lines
1.2 KiB
JavaScript
2 lines
1.2 KiB
JavaScript
import{b as i,c as M,h as l,d as O,e as T,f as s}from"./utils.DS2YS0tX.js";import{a0 as u}from"./exports.1ijyAKMZ.js";import{t as R}from"./index-c1cc4c86.RjqwfILA.js";const e={BOUTON_MENU_MOBILE:i(M),BOUTON_RETOUR_SOMMET:i("#bouton-retour-haut"),CORPS_HTML:i("body"),IMAGE_BOUTON:i("#bouton-retour-haut img")},o=2;let E=e.CORPS_HTML.getBoundingClientRect().height/window.innerHeight,n=window.scrollY,r=!1;const _=()=>window.scrollY,a=t=>{t?(e.BOUTON_RETOUR_SOMMET.setAttribute(O,""),e.BOUTON_RETOUR_SOMMET.setAttribute(T,"99"),e.IMAGE_BOUTON.removeAttribute(s)):(e.BOUTON_RETOUR_SOMMET.removeAttribute(O),e.BOUTON_RETOUR_SOMMET.setAttribute(T,"-2"),e.IMAGE_BOUTON.setAttribute(s,"")),r=!1},U=()=>{window.addEventListener("scroll",()=>{n=_(),!(E<o)&&(r||(r=!0,requestAnimationFrame(()=>a(n>window.innerHeight*o))))}),new ResizeObserver(t=>{u(l(t),R(B=>{E=e.CORPS_HTML.getBoundingClientRect().height/window.innerHeight,n=_()}))}).observe(e.CORPS_HTML),a(n>window.innerHeight*o)},d=()=>{e.BOUTON_RETOUR_SOMMET.addEventListener("click",t=>{t.preventDefault(),window.scrollTo({behavior:"smooth",top:0}),e.BOUTON_MENU_MOBILE.focus({preventScroll:!0})})};document.addEventListener("DOMContentLoaded",()=>{d(),U()});
|
|
//# sourceMappingURL=scripts-bouton-retour-sommet.js.map
|