efficient-storefront-blocks 0.134.1 → 0.134.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/index.js +25 -25
- package/dist/render/app/globals.css +8 -3
- package/dist/render/components/product-hero/SpinLayer.js +1 -1
- package/dist/render/lib/sections/spin-sets.d.ts +0 -2
- package/dist/render/lib/sections/spin-sets.js +1 -1
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +1 -1
|
@@ -4552,17 +4552,22 @@ em.text-accent {
|
|
|
4552
4552
|
top: 79.31cqw;
|
|
4553
4553
|
}
|
|
4554
4554
|
/* The 360° frames are white-ground renders: multiplied, their white is the
|
|
4555
|
-
ground and the floor shadows show under the wheel (SpinLayer).
|
|
4556
|
-
|
|
4555
|
+
ground and the floor shadows show under the wheel (SpinLayer). The frames'
|
|
4556
|
+
layer is multiplied as ONE picture: the two frames of a crossfade blend over
|
|
4557
|
+
each other first, as they are. Multiplied one by one, the next frame
|
|
4558
|
+
darkened the one under it and the wheel jumped bright at every step. */
|
|
4559
|
+
.sf-photo-ground-studio [data-spin-frames] {
|
|
4557
4560
|
mix-blend-mode: multiply;
|
|
4561
|
+
isolation: isolate;
|
|
4558
4562
|
}
|
|
4559
4563
|
/* The Flat ground on a light page (the well's `bg-bg`, ProductGallery
|
|
4560
4564
|
groundClass): multiplied too, so the frame's white is the page colour and no
|
|
4561
4565
|
white square shows on an off-white page. On a dark page the well has no
|
|
4562
4566
|
paint and the frame is drawn as it is: a white-ground render cannot sit on
|
|
4563
4567
|
a dark ground without its white. */
|
|
4564
|
-
.bg-bg > [data-spin-well] [data-spin-
|
|
4568
|
+
.bg-bg > [data-spin-well] [data-spin-frames] {
|
|
4565
4569
|
mix-blend-mode: multiply;
|
|
4570
|
+
isolation: isolate;
|
|
4566
4571
|
}
|
|
4567
4572
|
.sf-photo-ground-studio::after {
|
|
4568
4573
|
top: 78.75cqw;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as p,Fragment as le,jsxs as $}from"react/jsx-runtime";import{createContext as Ne,useCallback as ue,useContext as $e,useEffect as h,useRef as g,useState as d}from"react";import{VIEW_TABLET_MIN as Re}from"efficient-easel/screen/lib/content/view-tiers";import{cssStringBody as Oe}from"efficient-web-builder/format/lib/document/style-text";import{HALF_SIZES as R,sizedImage as Ce}from"efficient-web-builder/format/lib/sized-image";import{prefersReducedMotion as z}from"efficient-web-builder/render/components/useReducedMotion";import{STAGE_PHOTO_BOX as He}from"../../lib/sections/hero-gallery.js";import{DEFAULT_SPIN_AUTO_TURN as We,DEFAULT_SPIN_HINT as Ue,SPIN_RESUME_MS as je,isFullTurn as de,spinAutoTurnStep as Xe,spinBlend as ze,spinClampPosition as Be,spinFrameIndex as O,spinPositionAfterDrag as fe,spinCell as B,spinStartPosition as q}from"../../lib/sections/spin-sets.js";const qe=.3,Ge=.85,me=24,pe=4,he=1e3,ge=77/72,we=`${(1-ge)/2*100}%`,be=`${ge*100}%`,G={left:we,top:we,width:be,height:be},Ke=`(max-width: ${Re-.02}px)`,K=new Map,ve=new Map;function Z(t,y){let w=K.get(t);return w||(w=new Promise(M=>{const l=new Image,F=()=>{K.delete(t),ve.delete(t),M(null)},S=()=>M({w:l.naturalWidth,h:l.naturalHeight});l.onload=()=>{if(typeof l.decode!="function")return S();l.decode().then(S,F)},l.onerror=F,y&&(l.sizes=R,l.srcset=y),l.src=t,ve.set(t,l)}),K.set(t,w)),w}const Ze=Ne({autoTurn:We,turnHint:Ue}),Qe="M3 4.5c3.2 3.6 18.8 3.6 22 0M5.6 2.6 3 4.5l3 1.2M22.4 2.6 25 4.5l-3 1.2",L=t=>Ce(t,{fallbackWidth:he,maxWidth:he}),ye=(t,y)=>!!t.frames&&y===t.frames[0],Se=t=>({...G,backgroundImage:`url("${Oe(t.url)}")`,backgroundSize:`${t.cols*100}% ${t.rows*100}%`,backgroundPosition:`${t.cols>1?t.col*100/(t.cols-1):0}% ${t.rows>1?t.row*100/(t.rows-1):0}%`});function Ve({set:t,name:y,poster:w}){const[M,l]=d(null),F=g(null),[S,Q]=d(()=>q(t)),T=g(null),C=g(0),b=g(S),D=g(null),E=g(null),{autoTurn:f,turnHint:Ee}=$e(Ze),[ke,V]=d(!1),[xe,Y]=d(!1),[H,J]=d(0),ee=g(0),[Ae,te]=d(!1),[Pe,Fe]=d(!0),[ne,_e]=d(null),a=t.count,[W,re]=d(null),U=g(null),[k,oe]=d(null),v=de(t),x=O(S,a,v),_=t.frames?t.frames[x]:t.startFrame??"";h(()=>{const e=F.current;e?.complete&&e.naturalWidth>0&&l(_)},[_]);const I=ue(e=>{const n=Be(e,a,v);return b.current=n,Q(n),n},[a,v]),N=ue(()=>cancelAnimationFrame(C.current),[]);h(()=>{const e=window.matchMedia?.(Ke);if(!e)return oe(!1);const n=()=>oe(e.matches);return n(),e.addEventListener?.("change",n),()=>e.removeEventListener?.("change",n)},[]),h(()=>{if(!t.sheets||!t.startFrame||k===null)return;const e=k?t.sheets.phone:t.sheets.desktop,n=`${t.startFrame} ${e.urls[0]}`;if(E.current===n)return;E.current=n,re({key:n,sheet:e,ready:new Set});const r=Math.floor(q(t)/(e.cols*e.rows)),u=e.urls.map((c,o)=>e.urls[(r+o)%e.urls.length]),i=L(t.startFrame);Z(i.src,i.srcSet).then(()=>{for(const c of u)Z(c).then(o=>{!o||o.w!==e.cols*e.frame||o.h!==e.rows*e.frame||E.current===n&&re(m=>m?.key===n?{...m,ready:new Set(m.ready).add(c)}:m)})})},[t,k]),h(()=>{if(!t.frames)return;const e=t.frames,n=e[0];if(E.current===n)return;E.current=n;const r=O(q(t),a,de(t)),u=[];for(let c=0;c<pe;c+=1)for(let o=c;o<a;o+=pe)u.push((r+o)%a);const i=c=>{const o=L(e[c]);return Z(o.src,o.srcSet)};i(u[0]).then(()=>Promise.all(u.slice(1).map(i))).then(c=>{E.current===n&&c.every(Boolean)&&_e(n)})},[a,t]),h(()=>N,[N]),h(()=>{const e=T.current;if(!f||!e)return;if(typeof IntersectionObserver>"u")return te(!0);const n=new IntersectionObserver(r=>te(r.some(u=>u.isIntersecting)));return n.observe(e),()=>n.disconnect()},[f]),h(()=>{if(!f)return;const e=()=>Fe(document.visibilityState!=="hidden");return e(),document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[f]);const Ie=e=>{N(),f&&Y(!0),V(!0),e.currentTarget.setPointerCapture?.(e.pointerId),D.current={x0:e.clientX,f0:b.current,last:e.clientX,speed:0}},Le=e=>{const n=D.current,r=T.current;!n||!r||(n.speed=e.clientX-n.last,n.last=e.clientX,I(fe(n.f0,e.clientX-n.x0,r.clientWidth,a)))},se=()=>{const e=D.current;D.current=null,V(!1),f&&e&&(Y(!1),J(i=>i+1));const n=T.current;if(!e||!n||z())return;let r=Math.max(-me,Math.min(me,e.speed));const u=()=>{if(Math.abs(r)<qe)return;const i=fe(b.current,r,n.clientWidth,a);I(i)===i&&(r*=Ge,C.current=requestAnimationFrame(u))};C.current=requestAnimationFrame(u)},Me=e=>{const n=e.key==="ArrowRight"||e.key==="ArrowUp"?1:e.key==="ArrowLeft"||e.key==="ArrowDown"?-1:0;if(e.key==="Home")I(0);else if(e.key==="End")I(a-1);else if(n)I(Math.round(b.current)+n);else return;N(),f&&J(r=>r+1),e.preventDefault()},s=t.sheets&&W&&W.key.startsWith(`${t.startFrame} `)?W:null;s&&s.ready.has(B(s.sheet,x).url)&&(U.current={key:s.key,frame:x});const j=s&&U.current?.key===s.key?U.current.frame:null,A=s&&j!==null?{...B(s.sheet,j),cols:s.sheet.cols,rows:s.sheet.rows}:null,P=ze(S,a,v,z()),X=s&&P.b!==null&&j===x?B(s.sheet,P.b):null,ae=A&&X&&s.ready.has(X.url)?{...X,cols:A.cols,rows:A.rows}:null,ie=!s&&t.frames&&P.b!==null&&ye(t,ne)?t.frames[P.b]:null,Te=t.frames?ye(t,ne):!!s&&s.ready.size===s.sheet.urls.length,ce=f&&Te&&Ae&&Pe&&!xe;return h(()=>{if(!ce)return;const e=ee.current!==H;let n=-1,r=-1,u=1,i=0;const c=o=>{if(i=requestAnimationFrame(c),n<0&&(n=o),e&&o-n<je)return;if(ee.current=H,r<0){r=o;return}const m=Xe(t,b.current,u,o-r);r=o,u=m.way;const De=O(b.current,a,v);b.current=m.position,(!z()||O(m.position,a,v)!==De)&&Q(m.position)};return i=requestAnimationFrame(c),()=>cancelAnimationFrame(i)},[ce,H,t,a,v]),$("div",{ref:T,"data-spin-well":!0,role:"slider",tabIndex:0,"aria-label":`${y}, 360° view: drag or use the arrow keys to turn`,"aria-valuemin":1,"aria-valuemax":a,"aria-valuenow":x+1,"aria-valuetext":`Angle ${x+1} of ${a}`,"data-spin-auto-turn":f?"":void 0,onKeyDown:Me,className:"absolute inset-0 select-none overflow-hidden cursor-grab active:cursor-grabbing focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-fg",style:{touchAction:"pan-y"},onPointerDown:Ie,onPointerMove:Le,onPointerUp:se,onPointerCancel:se,onTouchStart:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),onTouchEnd:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[p("div",{"data-spin-frames":!0,className:"pointer-events-none absolute inset-0",children:A?$(le,{children:[p("div",{"data-spin-frame":!0,className:"pointer-events-none absolute",style:Se(A)}),ae?p("div",{"data-spin-frame":!0,className:"pointer-events-none absolute",style:{...Se(ae),opacity:P.mix}}):null]}):$(le,{children:[p("img",{...L(_),ref:F,onLoad:()=>l(_),sizes:R,alt:"",draggable:!1,fetchPriority:"high","data-spin-frame":!0,className:"pointer-events-none absolute max-w-none object-contain",style:G}),ie?p("img",{...L(ie),sizes:R,alt:"",draggable:!1,"data-spin-frame":!0,className:"pointer-events-none absolute max-w-none object-contain",style:{...G,opacity:P.mix}}):null]})}),w&&!A&&M!==_?p("img",{...L(w),sizes:R,alt:"",draggable:!1,"data-spin-poster":!0,className:`pointer-events-none absolute inset-[6%] ${He} object-contain`}):null,Ee&&!ke?$("span",{"data-spin-hint":!0,className:`pointer-events-none absolute inset-x-0 flex flex-col items-center gap-1 text-xs text-fg ${k?"bottom-3":"bottom-5"}`,children:[k?null:p("svg",{viewBox:"0 0 28 12",width:"28",height:"12","aria-hidden":"true",children:p("path",{d:Qe,fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),k?"Swipe to turn":"Drag to turn"]}):null]})}export{Ze as SpinChoices,Ve as default};
|
|
@@ -21,8 +21,6 @@ export type SpinSets = Record<string, Record<string, SpinSet>>;
|
|
|
21
21
|
export declare const DEFAULT_SPIN_AUTO_TURN = false;
|
|
22
22
|
export declare const DEFAULT_SPIN_HINT = false;
|
|
23
23
|
export declare function parseSpinSwitch(v: unknown): boolean;
|
|
24
|
-
export declare const SPIN_HINT_SHOW_MS = 1000;
|
|
25
|
-
export declare const SPIN_HINT_HIDE_MS = 6000;
|
|
26
24
|
export declare const SPIN_TURN_MS = 14000;
|
|
27
25
|
export declare const SPIN_RESUME_MS = 5000;
|
|
28
26
|
export declare const DEFAULT_SPIN_AUTO_ARC = 160;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveMedia as m}from"efficient-web-builder/render/lib/media";const
|
|
1
|
+
import{resolveMedia as m}from"efficient-web-builder/render/lib/media";const h=4096,c=360,y=.9,E=!1,U=!1;function F(n){return n===!0}const S=14e3,M=1e-6,j=5e3,g=160;function R(n,t,r,e){const o=n.autoArc??g;if(a(n)&&o<c)return d(n.count,o,t,r,e*n.count/S);const i=a(n)?c:n.arc,s=t+r*e*n.count*c/(S*i);if(a(n))return{position:(s%n.count+n.count)%n.count,way:r};const u=n.count-M;return s>=u?{position:u,way:-1}:s<=0?{position:0,way:1}:{position:s,way:r}}const _=n=>Array.isArray(n)&&n.length>0&&n.every(t=>typeof t=="string"&&t.length>0),x=n=>m(n)??n,p=n=>Number.isInteger(n)&&n>0;function A(n,t){if(!n||typeof n!="object")return null;const{frame:r,cols:e,rows:o,urls:i}=n;return!p(r)||!p(e)||!p(o)||!_(i)||r*e>h||r*o>h||i.length!==Math.ceil(t/(e*o))?null:{frame:r,cols:e,rows:o,urls:i.map(x)}}function T(n){const{frames:t,count:r,startFrame:e,sheets:o}=n,i=_(t)?{count:t.length,frames:t.map(x)}:null;if(o&&typeof o=="object"&&p(r)&&typeof e=="string"&&e){const s=A(o.desktop,r),u=A(o.phone,r);if(s&&u)return{count:r,startFrame:x(e),sheets:{desktop:s,phone:u}}}return i}function b(n){if(!n||typeof n!="object")return null;const{arc:t,start:r}=n,e=T(n);if(!e)return null;if(t!==void 0){if(typeof t!="number"||!(t>0&&t<=c))return null;e.arc=t}const{autoArc:o}=n;return typeof o=="number"&&o>0&&o<=c&&(e.autoArc=o),Number.isInteger(r)&&r>=0&&r<e.count&&(e.start=r),e}function L(n){if(!n||typeof n!="object"||Array.isArray(n))return{};const t={};for(const[r,e]of Object.entries(n)){if(!e||typeof e!="object"||Array.isArray(e))continue;const o={};for(const[i,s]of Object.entries(e)){const u=b(s);u&&(o[i]=u)}Object.keys(o).length>0&&(t[r]=o)}return t}function k(n,t,r){return r?n[t]?.[r]??null:null}function w(n,t){const r=Object.keys(n?.[t]??{});return r.length>0?{finish:r}:null}function a(n){return n.arc===void 0||n.arc>=c}function d(n,t,r,e,o){const i=n*t/(2*c),s=(r%n+n)%n,u=s>n/2?s-n:s;let f=u>i?-1:u<-i?1:e,l=u+f*o;return f===1&&u<=i&&l>=i?[l,f]=[i,-1]:f===-1&&u>=-i&&l<=-i&&([l,f]=[-i,1]),{position:(l%n+n)%n,way:f}}function N(n){return a(n)?0:Math.floor(n.count/2)}function D(n){return n.start??N(n)}function I(n,t,r=!0){return r?(Math.floor(n)%t+t)%t:Math.max(0,Math.min(t-1,Math.floor(n)))}function O(n,t,r,e){const o=I(n,t,r),i=n-Math.floor(n),s=r?(o+1)%t:o+1<t?o+1:null;return e||i===0||s===null?{a:o,b:null,mix:0}:{a:o,b:s,mix:i}}function C(n,t,r){return r?n:Math.max(0,Math.min(t-1,n))}function H(n,t,r,e){return r<=0?n:n-t/r*e*y}function B(n,t){const r=n.cols*n.rows,e=t%r;return{url:n.urls[Math.floor(t/r)],col:e%n.cols,row:Math.floor(e/n.cols)}}export{g as DEFAULT_SPIN_AUTO_ARC,E as DEFAULT_SPIN_AUTO_TURN,U as DEFAULT_SPIN_HINT,j as SPIN_RESUME_MS,h as SPIN_SHEET_MAX_SIDE,S as SPIN_TURN_MS,a as isFullTurn,L as parseSpinSets,F as parseSpinSwitch,R as spinAutoTurnStep,O as spinBlend,B as spinCell,C as spinClampPosition,I as spinFrameIndex,H as spinPositionAfterDrag,w as spinPreference,k as spinSetFor,D as spinStartPosition};
|