WordPress/wp-includes/blocks/image/view.min.js
Tammie Lister d605f96c0f Update npm packages to latest versions for 6.4 beta 3.
The npm packages needed a further update for beta 3 in preparation for 6.4.

Props @richtabor, @mmaattiiaass, @tellthemachines, @mamaduka, @swissspidy, @scruffian, @andraganescu, @andrewserong, @mujuonly, @get_dave, @ntsekouras, @carlosgprim, @ramonopoly, @jameskoster, @wildworks, @aaronrobertshaw, @czapla, @santosguillamot, @artemiosans, @afercia, @glendaviesnz, @kevin940726, @mikachan, @siobhyb.

See #59411.

Built from https://develop.svn.wordpress.org/trunk@56808


git-svn-id: http://core.svn.wordpress.org/trunk@56320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-09 17:24:24 +00:00

1 line
5.3 KiB
JavaScript

"use strict";(self.__WordPressPrivateInteractivityAPI__=self.__WordPressPrivateInteractivityAPI__||[]).push([[354],{699:function(e,t,i){var o=i(754);const n=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];let a,r=!1,c=0;function l(e){!r&&Date.now()-c>450&&window.scrollTo(e.core.image.scrollLeftReset,e.core.image.scrollTopReset)}(0,o.h)({state:{core:{image:{windowWidth:window.innerWidth,windowHeight:window.innerHeight}}},actions:{core:{image:{showLightbox:({context:e,event:t})=>{e.core.image.imageLoaded&&(e.core.image.initialized=!0,e.core.image.lastFocusedElement=window.document.activeElement,e.core.image.scrollDelta=0,e.core.image.lightboxEnabled=!0,function(e,t){let{naturalWidth:i,naturalHeight:o,offsetWidth:n,offsetHeight:a}=t.target.previousElementSibling,{x:r,y:c}=t.target.previousElementSibling.getBoundingClientRect();const l=i/o;let g=n/a;if("contain"===e.core.image.scaleAttr)if(l>g){const e=n/l;c+=(a-e)/2,a=e}else{const e=a*l;r+=(n-e)/2,n=e}g=n/a;let d=parseFloat("none"!==e.core.image.targetWidth?e.core.image.targetWidth:i),s=parseFloat("none"!==e.core.image.targetHeight?e.core.image.targetHeight:o),m=d/s,h=d,u=s,f=d,w=s;if(l.toFixed(2)!==m.toFixed(2)){if(l>m){const e=d/l;s-e>d?(s=e,d=e*l):s=d/l}else{const e=s*l;d-e>s?(d=e,s=e/l):d=s*l}f=d,w=s,m=d/s,g>m?(h=d,u=h/g):(u=s,h=u*g)}(n>f||a>w)&&(f=n,w=a);let b=0;window.innerWidth>480?b=80:window.innerWidth>1920&&(b=160);const x=80,p=Math.min(window.innerWidth-b,f),E=Math.min(window.innerHeight-x,w);g>p/E?(f=p,w=f/g):(w=E,f=w*g);const v=n/f,y=d*(f/h),A=s*(w/u);let L=document.getElementById("wp-lightbox-styles");L||(L=document.createElement("style"),L.id="wp-lightbox-styles",document.head.appendChild(L));L.innerHTML=`\n\t\t:root {\n\t\t\t--wp--lightbox-initial-top-position: ${c}px;\n\t\t\t--wp--lightbox-initial-left-position: ${r}px;\n\t\t\t--wp--lightbox-container-width: ${f+1}px;\n\t\t\t--wp--lightbox-container-height: ${w+1}px;\n\t\t\t--wp--lightbox-image-width: ${y}px;\n\t\t\t--wp--lightbox-image-height: ${A}px;\n\t\t\t--wp--lightbox-scale: ${v};\n\t\t}\n\t`}(e,t),e.core.image.scrollTopReset=window.pageYOffset||document.documentElement.scrollTop,e.core.image.scrollLeftReset=window.pageXOffset||document.documentElement.scrollLeft,a=l.bind(null,e),window.addEventListener("scroll",a,!1))},hideLightbox:async({context:e})=>{e.core.image.hideAnimationEnabled=!0,e.core.image.lightboxEnabled&&(setTimeout((function(){window.removeEventListener("scroll",a)}),450),e.core.image.lightboxEnabled=!1,e.core.image.lastFocusedElement.focus({preventScroll:!0}))},handleKeydown:({context:e,actions:t,event:i})=>{e.core.image.lightboxEnabled&&("Tab"!==i.key&&9!==i.keyCode||(i.shiftKey&&window.document.activeElement===e.core.image.firstFocusableElement?(i.preventDefault(),e.core.image.lastFocusableElement.focus()):i.shiftKey||window.document.activeElement!==e.core.image.lastFocusableElement||(i.preventDefault(),e.core.image.firstFocusableElement.focus())),"Escape"!==i.key&&27!==i.keyCode||t.core.image.hideLightbox({context:e,event:i}))},handleLoad:({state:e,context:t,effects:i,ref:o})=>{t.core.image.imageLoaded=!0,t.core.image.imageCurrentSrc=o.currentSrc,i.core.image.setButtonStyles({state:e,context:t,ref:o})},handleTouchStart:()=>{r=!0},handleTouchMove:({context:e,event:t})=>{e.core.image.lightboxEnabled&&t.preventDefault()},handleTouchEnd:()=>{c=Date.now(),r=!1}}}},selectors:{core:{image:{roleAttribute:({context:e})=>e.core.image.lightboxEnabled?"dialog":null,ariaModal:({context:e})=>e.core.image.lightboxEnabled?"true":null,dialogLabel:({context:e})=>e.core.image.lightboxEnabled?e.core.image.dialogLabel:null,lightboxObjectFit:({context:e})=>{if(e.core.image.initialized)return"cover"},enlargedImgSrc:({context:e})=>e.core.image.initialized?e.core.image.imageUploadedSrc:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="}}},effects:{core:{image:{setCurrentSrc:({context:e,ref:t})=>{t.complete&&(e.core.image.imageLoaded=!0,e.core.image.imageCurrentSrc=t.currentSrc)},initLightbox:async({context:e,ref:t})=>{if(e.core.image.figureRef=t.querySelector("figure"),e.core.image.imageRef=t.querySelector("img"),e.core.image.lightboxEnabled){const i=t.querySelectorAll(n);e.core.image.firstFocusableElement=i[0],e.core.image.lastFocusableElement=i[i.length-1],t.querySelector(".close-button").focus()}},setButtonStyles:({state:e,context:t,ref:i})=>{const{naturalWidth:o,naturalHeight:n,offsetWidth:a,offsetHeight:r}=i;if(0!==o&&0!==n)if((e.core.image.windowWidth||e.core.image.windowHeight)&&"contain"===t.core.image.scaleAttr){const e=o/n;if(e>a/r){t.core.image.imageButtonWidth=a;const i=a/e;t.core.image.imageButtonHeight=i,t.core.image.imageButtonTop=(r-i)/2}else{t.core.image.imageButtonHeight=r;const i=r*e;t.core.image.imageButtonWidth=i,t.core.image.imageButtonLeft=(a-i)/2}}else t.core.image.imageButtonWidth=a,t.core.image.imageButtonHeight=r}}}}},{afterLoad:({state:e})=>{window.addEventListener("resize",function(e,t=50){let i;return()=>{const o=()=>{i=null,e()};clearTimeout(i),i=setTimeout(o,t)}}((()=>{e.core.image.windowWidth=window.innerWidth,e.core.image.windowHeight=window.innerHeight})))}})}},function(e){var t;t=699,e(e.s=t)}]);