@fynd-design-engineering/fynd-one-v2 3.3.30 → 3.3.31
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/dist/accordians/index.js +1 -1
- package/package.json +1 -1
package/dist/accordians/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[fynd-faq-element="wrapper"]').forEach(
|
|
1
|
+
"use strict";(()=>{document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[fynd-faq-element="wrapper"]').forEach(t=>{let e=t.querySelector('[fynd-faq-element="toggle"]'),n=t.querySelector('[fynd-faq-element="content"]'),i=t.querySelector('[fynd-faq-element="content-inner"]'),l=e?.querySelector('[fynd-faq-element="x-line"]')||null,u=e?.querySelector('[fynd-faq-element="y-line"]')||null;if(!e||!n||!i||!l||!u){console.warn("Required FAQ elements not found in wrapper");return}let a=t.closest("[fynd-faq-group]"),r=a?.getAttribute("fynd-faq-group")||null,s=a?.getAttribute("fynd-faq-type")||"one-at-a-time";t.getAttribute("fynd-faq-initialopen")==="true"?(gsap.set(n,{height:"auto",overflow:"hidden"}),gsap.set(i,{opacity:1}),gsap.set(l,{rotation:180}),gsap.set(u,{rotation:270}),e.setAttribute("data-state","open"),g(t,r),q(t,r),p(t,r),h(t,r)):(gsap.set(n,{height:0}),gsap.set(i,{opacity:0}),gsap.set(l,{rotation:0}),gsap.set(u,{rotation:0}),e.setAttribute("data-state","closed"));let c=!1;e.addEventListener("click",()=>{if(c)return;c=!0;let f=e.getAttribute("data-state")==="open";if(s==="one-at-a-time"&&a){let E=a.querySelectorAll('[fynd-faq-element="wrapper"] [data-state="open"]');if(f&&E.length===1){c=!1;return}}f?y(t,()=>{c=!1}):(s==="one-at-a-time"&&a&&L(a),A(t,r,()=>{c=!1}))})}),m(),T(),setTimeout(H,500)});window.addEventListener("resize",()=>{m()});function m(){if(window.innerWidth<992)return;document.querySelectorAll("[fynd-faq-image-target]").forEach(e=>{let n=e.parentElement;!n||n.getAttribute("ratio-height")!=="true"||(n.style.height="auto",requestAnimationFrame(()=>{let l=n.offsetHeight;n.style.height=`${l}px`}))}),document.querySelectorAll('[fynd-faq-tabgroup][ratio-height="true"]').forEach(e=>{e.style.height="auto",requestAnimationFrame(()=>{let n=e.offsetHeight;e.style.height=`${n}px`})})}function A(o,t,e){let n=o.querySelector('[fynd-faq-element="toggle"]'),i=o.querySelector('[fynd-faq-element="content"]'),l=o.querySelector('[fynd-faq-element="content-inner"]'),u=n?.querySelector('[fynd-faq-element="x-line"]')||null,a=n?.querySelector('[fynd-faq-element="y-line"]')||null;if(!n||!i||!l||!u||!a){console.warn("Required elements not found for opening accordion");return}i.gsapAnimation&&i.gsapAnimation.kill();let r=gsap.timeline({onComplete:()=>e&&e()});gsap.set(i,{height:"auto",visibility:"hidden",opacity:0});let s=i.offsetHeight;gsap.set(i,{height:0,visibility:"visible",opacity:1}),r.to(u,{rotation:180,duration:.4,ease:"power2.inOut"},0),r.to(a,{rotation:270,duration:.4,ease:"power2.inOut"},0),r.to(i,{height:s,duration:.5,ease:"power3.inOut",clearProps:"height",onComplete:()=>{i.style.height="auto"}},0),r.to(l,{opacity:1,duration:.4,ease:"power2.out"},"-=0.35"),i.gsapAnimation=r,n.setAttribute("data-state","open"),window.innerWidth<992&&setTimeout(()=>{b(o)},600);let c=n.querySelector('[fynd-faq-element="chevron"]');c&&gsap.to(c,{rotation:180,duration:.4,ease:"back.out(1.7)"}),g(o,t),q(o,t),p(o,t),h(o,t)}function y(o,t){let e=o.querySelector('[fynd-faq-element="toggle"]'),n=o.querySelector('[fynd-faq-element="content"]'),i=o.querySelector('[fynd-faq-element="content-inner"]'),l=e?.querySelector('[fynd-faq-element="x-line"]')||null,u=e?.querySelector('[fynd-faq-element="y-line"]')||null;if(!e||!n||!i||!l||!u){console.warn("Required elements not found for closing accordion");return}n.gsapAnimation&&n.gsapAnimation.kill();let a=n.offsetHeight;n.style.height=`${a}px`;let r=gsap.timeline({onComplete:()=>t&&t()});r.to(l,{rotation:0,duration:.4,ease:"power2.inOut"},0),r.to(u,{rotation:0,duration:.4,ease:"power2.inOut"},0),r.to(i,{opacity:0,duration:.3,ease:"power2.in"},0),r.to(n,{height:0,duration:.4,ease:"power3.inOut"},"-=0.25"),n.gsapAnimation=r,e.setAttribute("data-state","closed");let s=e.querySelector('[fynd-faq-element="chevron"]');s&&gsap.to(s,{rotation:0,duration:.4,ease:"back.out(1.7)"})}function L(o){o.querySelectorAll('[fynd-faq-element="wrapper"] [data-state="open"]').forEach(e=>{let n=e.closest('[fynd-faq-element="wrapper"]');n&&y(n)})}function g(o,t){if(!t)return;let e=document.querySelector(`[fynd-faq-image-target="${t}"]`);if(!e)return;let n=o.querySelector("[fynd-faq-image-source]");if(!n)return;let i=n.getAttribute("src"),l=n.getAttribute("srcset");i&&e.setAttribute("src",i),l&&e.setAttribute("srcset","")}function q(o,t){if(!t)return;let e=document.querySelector(`[fynd-faq-text-target="${t}"]`);if(!e)return;let n=o.querySelector("[fynd-faq-text-source]");n&&(e.textContent=n.textContent)}function p(o,t){if(!t)return;let e=document.querySelector(`[fynd-faq-button-text-target="${t}"]`),n=document.querySelector(`[fynd-faq-button-link-target="${t}"]`),i=o.querySelector("[fynd-faq-link-source]");if(i&&(e&&(e.textContent=i.textContent),n))for(let l=0;l<i.attributes.length;l++){let u=i.attributes[l];n.setAttribute(u.name,u.value)}}function h(o,t){if(!t)return;let e=document.querySelector(`[fynd-faq-video-target="${t}"]`);if(!e)return;let n=o.querySelector("[fynd-faq-video]");if(!n)return;let i=o.querySelector("[fynd-faq-image]");if(!i)return;let l=o.querySelector("[fynd-faq-video-source]");if(l)window.innerWidth<992&&(n.style.display="block",i.style.display="none",l.setAttribute("loop",""),l.setAttribute("autoplay",""),l.setAttribute("muted",""),l.setAttribute("playsinline",""),d(l));else{e.style.display="none",window.innerWidth<992&&(n.style.display="none",i.style.display="block");return}let u=l.querySelector("source"),a=u?.getAttribute("src")||null,r=u?.getAttribute("type")||null;if(a&&a.trim()!==""){let s=e.querySelector("source");s||(s=document.createElement("source"),e.appendChild(s)),s.setAttribute("src",a),s.setAttribute("type",r||"video/mp4"),e.setAttribute("loop",""),e.setAttribute("autoplay",""),e.setAttribute("muted",""),e.setAttribute("playsinline",""),window.innerWidth<992&&(l.setAttribute("loop",""),l.setAttribute("autoplay",""),l.setAttribute("muted",""),l.setAttribute("playsinline",""),l.play());try{e.load()}catch{}d(e),e.style.display="block"}else{e.style.display="none";let s=e.querySelector("source");if(s){s.removeAttribute("src"),s.removeAttribute("type");try{e.load()}catch{}}}}function d(o){!o.isConnected||o.style.display==="none"||requestAnimationFrame(()=>{let t=o.play();t&&typeof t.catch=="function"&&t.catch(()=>{})})}function T(){let o=document.querySelectorAll("[fynd-faq-video-target]");if(!o.length)return;let t=new IntersectionObserver(e=>{e.forEach(n=>{let i=n.target;if(!(!i.querySelector("source[src]")||i.style.display==="none"))if(n.isIntersecting&&n.intersectionRatio>=.5)i.setAttribute("autoplay",""),i.setAttribute("muted",""),i.setAttribute("playsinline",""),i.setAttribute("loop",""),d(i);else try{i.pause()}catch{}})},{threshold:[0,.5,1]});o.forEach(e=>t.observe(e))}async function H(){let o=document.querySelectorAll("video[fynd-faq-video-target], video.fynd-faq-video-target, video[data-fynd-faq-video-target], video[fynd-faq-video-source]");for(let t of o)if(t.src||t.querySelector("source[src]")){t.setAttribute("muted",""),t.setAttribute("playsinline",""),t.setAttribute("autoplay",""),t.setAttribute("loop",""),t.preload="auto",t.muted=!0;try{await t.play()}catch{}}}function b(o){if(!o)return;let t=o.querySelector('[fynd-faq-element="scroll-trigger"]');if(!t){console.warn('No element with [fynd-faq-element="scroll-trigger"] found inside the wrapper:',o);return}t.scrollIntoView({behavior:"smooth"})}})();
|
package/package.json
CHANGED