{"version":3,"file":"draggable_controller-DvkrBqLY.js","sources":["../../../app/javascript/controllers/util/draggable_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n initialize() {\n this.onMouseDown = this.onMouseDown.bind(this)\n this.onMouseMove = this.onMouseMove.bind(this)\n this.onMouseUp = this.onMouseUp.bind(this)\n\n super.initialize()\n }\n\n connect() {\n this.element.addEventListener('mousedown', this.onMouseDown)\n\n super.connect()\n }\n\n disconnect() {\n this.element.removeEventListener('mousedown', this.onMouseDown)\n\n super.disconnect()\n }\n\n onMouseDown(event) {\n this.offsetX = event.clientX - this.element.getBoundingClientRect().left\n this.offsetY = event.clientY - this.element.getBoundingClientRect().top\n\n document.addEventListener('mousemove', this.onMouseMove)\n document.addEventListener('mouseup', this.onMouseUp)\n }\n\n onMouseMove(event) {\n if (this.offsetX && this.offsetY) {\n this.element.classList.add('select-none')\n\n this.element.style.left = `${event.clientX - this.offsetX}px`\n this.element.style.top = `${event.clientY - this.offsetY}px`\n }\n }\n\n onMouseUp() {\n this.element.classList.remove('select-none')\n\n document.removeEventListener('mousemove', this.onMouseMove)\n document.removeEventListener('mouseup', this.onMouseUp)\n\n this.offsetX = null\n this.offsetY = null\n }\n}\n"],"names":["draggable_controller","ApplicationController","event"],"mappings":"mDAEe,MAAKA,UAASC,CAAsB,CACjD,YAAa,CACX,KAAK,YAAc,KAAK,YAAY,KAAK,IAAI,EAC7C,KAAK,YAAc,KAAK,YAAY,KAAK,IAAI,EAC7C,KAAK,UAAY,KAAK,UAAU,KAAK,IAAI,EAEzC,MAAM,WAAU,CACpB,CAEE,SAAU,CACR,KAAK,QAAQ,iBAAiB,YAAa,KAAK,WAAW,EAE3D,MAAM,QAAO,CACjB,CAEE,YAAa,CACX,KAAK,QAAQ,oBAAoB,YAAa,KAAK,WAAW,EAE9D,MAAM,WAAU,CACpB,CAEE,YAAYC,EAAO,CACjB,KAAK,QAAUA,EAAM,QAAU,KAAK,QAAQ,wBAAwB,KACpE,KAAK,QAAUA,EAAM,QAAU,KAAK,QAAQ,wBAAwB,IAEpE,SAAS,iBAAiB,YAAa,KAAK,WAAW,EACvD,SAAS,iBAAiB,UAAW,KAAK,SAAS,CACvD,CAEE,YAAYA,EAAO,CACb,KAAK,SAAW,KAAK,UACvB,KAAK,QAAQ,UAAU,IAAI,aAAa,EAExC,KAAK,QAAQ,MAAM,KAAO,GAAGA,EAAM,QAAU,KAAK,OAAO,KACzD,KAAK,QAAQ,MAAM,IAAM,GAAGA,EAAM,QAAU,KAAK,OAAO,KAE9D,CAEE,WAAY,CACV,KAAK,QAAQ,UAAU,OAAO,aAAa,EAE3C,SAAS,oBAAoB,YAAa,KAAK,WAAW,EAC1D,SAAS,oBAAoB,UAAW,KAAK,SAAS,EAEtD,KAAK,QAAU,KACf,KAAK,QAAU,IACnB,CACA"}