-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchunk-LW4VTGYZ.js
executable file
·1 lines (1 loc) · 3.26 KB
/
chunk-LW4VTGYZ.js
1
import{a}from"./chunk-RHT2WMLP.js";import{t as I}from"./chunk-7TRK3HOB.js";import{$ as f,$a as p,B as E,Bc as b,F as _,Ua as h,db as T,eb as C,fa as n,za as u}from"./chunk-TLQ7SHBH.js";var S=".docs-reference-header",R=".docs-reference-members-container",N=".adev-reference-tab-body",O="data-tab",v="data-tab-url",P="API",B="tab",x=".docs-reference-api-tab",M=".docs-reference-member-card",l="hljs-ln-line-highlighted";var m="member-id";var L=20,g=20,G=(()=>{let s=class s{constructor(){this.destroyRef=n(p),this.document=n(b),this.injector=n(u),this.ngZone=n(T),this.window=n(I),this.cardOffsetTop=new Map,this.resizeObserver=null,this.membersMarginTopInPx=h(0)}ngOnDestroy(){this.resizeObserver?.disconnect()}setupListeners(e){this.setupCodeToCListeners(e),this.setupMemberCardListeners(),this.setScrollEventHandlers(),this.listenToResizeCardContainer()}updateMembersMarginTop(e){let t=this.document.querySelector(e);t&&this.updateMarginTopWhenTabBodyIsResized(t)}setupCodeToCListeners(e){let t=this.document.querySelector(e);t&&this.ngZone.runOutsideAngular(()=>{E(t,"click").pipe(a(this.destroyRef)).subscribe(i=>{let c=i.target instanceof HTMLButtonElement?i.target:this.findButtonElement(i.target),o=this.getMemberId(c);if(o){let r=this.document.querySelector(`#${o}`);this.scrollToCard(r)}})})}setupMemberCardListeners(){this.ngZone.runOutsideAngular(()=>{this.getAllMemberCards().forEach(e=>{this.cardOffsetTop.set(e.id,e.offsetTop),E(e,"click").pipe(a(this.destroyRef)).subscribe(()=>{this.scrollToCard(e)})})})}setScrollEventHandlers(){let e=E(this.document,"scroll").pipe(_(L),a(this.destroyRef));this.ngZone.runOutsideAngular(()=>{e.subscribe(()=>this.setActiveCodeLine())})}listenToResizeCardContainer(){let e=this.document.querySelector(R);e&&C(()=>{let t=new ResizeObserver(()=>{this.updateCardsOffsetTop(),this.setActiveCodeLine()});t.observe(e),this.destroyRef.onDestroy(()=>t.disconnect())},{injector:this.injector})}setActiveCodeLine(){let e=Array.from(this.cardOffsetTop).filter(([r,A])=>A<this.window.scrollY+this.membersMarginTopInPx()+g).pop();if(!e)return;let t=this.document.querySelectorAll(`button.${l}`),i=t.length>0?t.item(0):null,c=this.getMemberId(i),o=e[0];if(c&&c!==o){for(let r of Array.from(t))r.classList.remove(l);this.getAllMemberCards().forEach(r=>{r.blur()})}else{let r=this.document.querySelectorAll(`button[${m}="${o}"]`);for(let A of Array.from(r))A.classList.add(l);this.document.getElementById(`${o}`)?.focus()}}scrollToCard(e){e&&(e.focus(),this.window.scrollTo({top:e.offsetTop-this.membersMarginTopInPx(),behavior:"smooth"}))}updateCardsOffsetTop(){this.getAllMemberCards().forEach(e=>{this.cardOffsetTop.set(e.id,e.offsetTop)})}getAllMemberCards(){return this.document.querySelectorAll(`${M}`)}getMemberId(e){if(e)return e.attributes.getNamedItem(m)?.value}updateMarginTopWhenTabBodyIsResized(e){this.resizeObserver?.disconnect(),this.resizeObserver=new ResizeObserver(t=>{this.ngZone.run(()=>{e.offsetTop&&this.membersMarginTopInPx.set(e.offsetTop)})}),this.resizeObserver.observe(e)}findButtonElement(e){let t=e.parentElement;for(;t;){if(t instanceof HTMLButtonElement)return t;t=t.parentElement}return null}};s.\u0275fac=function(t){return new(t||s)},s.\u0275prov=f({token:s,factory:s.\u0275fac});let d=s;return d})();export{S as a,R as b,N as c,O as d,v as e,P as f,B as g,x as h,G as i};