@veltdev/sdk
Version:
Velt is an SDK to add collaborative features to your product within minutes. Example: Comments like Figma, Frame.io, Google docs or sheets, Recording like Loom, Huddles like Slack and much more.
2 lines (1 loc) • 2.25 kB
JavaScript
import{Ga as c,Pa as n,Wa as o,li as h,ua as a,wa as r}from"./chunk-GR3NESUB.js";var I=(()=>{let e=class e{constructor(t,i){this.domService=t,this.elementRef=i,this.clickOutside=new c}ngOnInit(){}ngAfterViewInit(){setTimeout(()=>{this.subscription=this.domService.onDocumentClickSubject$().subscribe(t=>{let i=this.checkInsideClick(t,this.elementRef.nativeElement);!i&&this.clickOutsideHandler&&typeof this.clickOutsideHandler=="function"&&(i=this.clickOutsideHandler(t.target,this.elementRef.nativeElement)),i||this.clickOutside.emit()})},500)}ngOnDestroy(){this.subscription?.unsubscribe()}checkInsideClick(t,i){return t.composedPath().includes(i)}};e.\u0275fac=function(i){return new(i||e)(n(h),n(r))},e.\u0275dir=o({type:e,selectors:[["","snippylyClickOutside",""]],inputs:{clickOutsideHandler:"clickOutsideHandler"},outputs:{clickOutside:"clickOutside"}});let s=e;return s})();var b=(()=>{let e=class e{constructor(t){this.elementRef=t,this.lastPosition=null,this.positionChange=new c,this.disabled=!1,this.timeSpentInMs=0,this.MAX_TIME_SPENT_IN_MS=6e4}ngAfterViewInit(){try{this.toggleTrackingPosition()}catch{}}toggleTrackingPosition(){try{this.disabled?this.stopTracking():this.startTrackingPosition()}catch{}}startTrackingPosition(){try{if(this.intervalId)return;this.intervalId=setInterval(()=>{if(this.timeSpentInMs+=10,this.timeSpentInMs>this.MAX_TIME_SPENT_IN_MS){this.stopTracking();return}let t=this.elementRef.nativeElement.getBoundingClientRect();(!this.lastPosition||!this.arePositionsEqual(this.lastPosition,t))&&(this.lastPosition=t,this.positionChange.emit(t))},10)}catch{}}stopTracking(){try{this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null,this.timeSpentInMs=0)}catch{}}arePositionsEqual(t,i){try{return t.top===i.top&&t.left===i.left&&t.bottom===i.bottom&&t.right===i.right&&t.width===i.width&&t.height===i.height}catch{return!0}}ngOnChanges(){try{this.toggleTrackingPosition()}catch{}}ngOnDestroy(){try{this.stopTracking()}catch{}}};e.\u0275fac=function(i){return new(i||e)(n(r))},e.\u0275dir=o({type:e,selectors:[["","veltPositionObserver",""]],inputs:{disabled:[0,"veltPositionObserverDisabled","disabled"]},outputs:{positionChange:"positionChange"},features:[a]});let s=e;return s})();export{I as a,b};