ray-template/docs/assets/reference_hooks_browser.md.D5n_xtb0.lean.js

2 lines
2.3 KiB
JavaScript

import{a8 as P,a9 as j,S as O,p as I,d as R,aa as N,o as C,c as D,E as b,k as c,w as V,a as Y,t as M,_ as z,a3 as f}from"./chunks/framework.BNdm2jZV.js";import{u as H}from"./chunks/unref-element.DLBcf5mH.js";import{B as $}from"./chunks/Button.B5dXaugh.js";import"./chunks/Loading.CYk0ZDH9.js";function G(n){return P()?(j(n),!0):!1}let L=999;const r="data-element-fullscreen",g=new WeakSet,X=(n,d)=>{const{beforeEnter:i,beforeExit:h,enter:p,exit:t,backgroundColor:y,zIndex:A,transition:B="all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"}={},k=I(!1);let l,a;const E=()=>{a&&(h==null||h(),a(),t==null||t())},F=()=>{const s=H(n);if(!(s instanceof HTMLElement)||g.has(s))return;a&&E(),i==null||i();const{top:_,left:x,width:S,height:T}=s.getBoundingClientRect(),u={position:"fixed","box-sizing":"border-box",top:`${_}px`,left:`${x}px`,width:`${S}px`,height:`${T}px`,transform:"translate(0, 0)","z-index":String(A??++L),transition:"none",...y?{"background-color":y}:{}},w=Object.keys(u).map(e=>[e,s.style.getPropertyValue(e),s.style.getPropertyPriority(e)]),m=s.getAttribute(r);g.add(s),a=()=>{l!==void 0&&cancelAnimationFrame(l),l=void 0;for(const[e,o,q]of w)s.style.setProperty(e,o,q);m===null?s.removeAttribute(r):s.setAttribute(r,m),a=void 0,g.delete(s),k.value=!1},s.setAttribute(r,"true");for(const[e,o]of Object.entries(u))s.style.setProperty(e,o);s.offsetHeight,s.style.transition=B,l=requestAnimationFrame(()=>{Object.assign(s.style,{top:"0px",left:"0px",width:"100dvw",height:"100dvh"}),l=void 0}),k.value=!0,p==null||p()},v=()=>{k.value?E():F()};return G(()=>{a&&(a(),t==null||t())}),{enter:F,exit:E,toggleFullscreen:v,isFullscreen:O(k)}},W={ref:"preview",class:"ray-demo fullscreen-demo"},J=R({__name:"FullscreenDemo",setup(n){const{isFullscreen:d,toggleFullscreen:i}=X(N("preview"));return(h,p)=>(C(),D("div",W,[b(c($),{onClick:c(i)},{default:V(()=>[Y(M(c(d)?"退出全屏 / Exit full screen":"元素全屏 / Full screen"),1)]),_:1},8,["onClick"])],512))}}),U=z(J,[["__scopeId","data-v-0d48cce2"]]),as=JSON.parse('{"title":"窗口、全屏和日期","description":"","frontmatter":{},"headers":[],"relativePath":"reference/hooks/browser.md","filePath":"reference/hooks/browser.md"}'),Z={name:"reference/hooks/browser.md"},es=Object.assign(Z,{setup(n){return(d,i)=>(C(),D("div",null,[i[0]||(i[0]=f("",6)),b(U),i[1]||(i[1]=f("",10))]))}});export{as as __pageData,es as default};