@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.54 kB
JavaScript
import{a as o}from"./chunk-KEET32BV.js";import{Pa as g,U as c,Wa as l,di as v,k as s}from"./chunk-GR3NESUB.js";var p=(()=>{let i=class i{constructor(e,r){this.loggingService=e,this.dragDrop=r,this.currentX=0,this.currentY=0,this.destroy$=new s,this.subscriptions=[],this.loggingService.log("%c[WB] Creating CLASS: DraggableOverlayDirective","color: blue;")}ngOnInit(){try{this.loggingService.log("%c[WB] Calling DraggableOverlayDirective FUNCTION: ngOnInit","color: green;"),this.setupDraggableOverlay()}catch(e){this.loggingService.catch("Error in DraggableOverlayDirective ngOnInit: ",e)}}setupDraggableOverlay(){try{if(this.loggingService.log("%c[WB] Calling DraggableOverlayDirective FUNCTION: setupDraggableOverlay","color: green;"),this.connectedOverlay&&this.connectedOverlay.overlayRef){let e=this.connectedOverlay.overlayRef.overlayElement;this.dragRef=this.dragDrop.createDrag(e),this.subscriptions.push(this.dragRef.moved.pipe(c(this.destroy$)).subscribe(r=>{let a=this.connectedOverlay?.overlayRef.getConfig().positionStrategy;this.updatePosition(a,r.distance.x,r.distance.y)},r=>{this.loggingService.catch("Error in DraggableOverlayDirective dragRef.moved subscription: ",r)})),this.dragRef.ended.pipe(c(this.destroy$)).subscribe(r=>{this.currentX+=r.distance.x,this.currentY+=r.distance.y},r=>{this.loggingService.catch("Error in DraggableOverlayDirective dragRef.ended subscription: ",r)})}}catch(e){this.loggingService.catch("Error in DraggableOverlayDirective setupDraggableOverlay: ",e)}}updatePosition(e,r,a){try{if(e){let n=this.currentX+r,h=this.currentY+a;e.withDefaultOffsetX(n).withDefaultOffsetY(h),this.connectedOverlay?.overlayRef?.updatePosition()}}catch{}}cleanupDraggableOverlay(){try{this.loggingService.log("%c[WB] Calling DraggableOverlayDirective FUNCTION: cleanupDraggableOverlay","color: green;"),this.dragRef&&this.dragRef.dispose()}catch(e){this.loggingService.catch("Error in DraggableOverlayDirective cleanupDraggableOverlay: ",e)}}ngOnDestroy(){try{this.loggingService.log("%c[WB] Calling DraggableOverlayDirective FUNCTION: ngOnDestroy","color: green;"),this.cleanupDraggableOverlay(),this.destroy$.next(),this.destroy$.complete(),this.subscriptions.forEach(e=>{e.unsubscribe()})}catch(e){this.loggingService.catch("Error in DraggableOverlayDirective ngOnDestroy: ",e)}}};i.\u0275fac=function(r){return new(r||i)(g(v),g(o))},i.\u0275dir=l({type:i,selectors:[["","veltDraggableOverlay",""]],inputs:{connectedOverlay:[0,"veltDraggableOverlay","connectedOverlay"]}});let t=i;return t})();export{p as a};