"use strict";const o=require("./base-iCmnU-fv.js"),t=require("./index-Ul6uY51t.js");class s{optionsDrag;_isDragging;_bindRunDragStart;_bindRunDragIng;_bindRunDragEnd;constructor(n,i){this.optionsDrag=i,this._isDragging=!1,this._init(n)}_init(n){this._bindRunDragStart=this._runDragStart.bind(this),this._bindRunDragIng=this._runDraggIng.bind(this),this._bindRunDragEnd=this._runDragEnd.bind(this),t.CommonElement.onListener(n,"mousedown",this._bindRunDragStart),t.CommonElement.onListener(n,"touchstart",this._bindRunDragStart)}_runDragStart(n){if(this._isDragging)return;const i=t.CommonElement.getClientXY(n);let e=!0;this.optionsDrag.start&&(e=this.optionsDrag.start(n,i)),e=o.CommonBase.isBoolean(e)?e:!0,e?(n.preventDefault(),n.stopPropagation(),document.onselectstart=()=>!1,document.ondragstart=()=>!1,this._isDragging=!0,t.CommonElement.onListener(window,"mousemove",this._bindRunDragIng),t.CommonElement.onListener(window,"touchmove",this._bindRunDragIng),t.CommonElement.onListener(window,"mouseup",this._bindRunDragEnd),t.CommonElement.onListener(window,"touchend",this._bindRunDragEnd),t.CommonElement.onListener(window,"contextmenu",this._bindRunDragEnd)):this._isDragging=!1}_runDraggIng(n){if(!this._isDragging)return;const i=t.CommonElement.getClientXY(n);this.optionsDrag.ing&&this.optionsDrag.ing(n,i)}_runDragEnd(n){if(!this._isDragging)return;this._isDragging=!1;const i=t.CommonElement.getClientXY(n);this.optionsDrag.end&&this.optionsDrag.end(n,i),this._offListener()}_offListener(){t.CommonElement.offListener(window,"mousemove",this._bindRunDragIng),t.CommonElement.offListener(window,"touchmove",this._bindRunDragIng),t.CommonElement.offListener(window,"mouseup",this._bindRunDragEnd),t.CommonElement.offListener(window,"touchend",this._bindRunDragEnd),t.CommonElement.offListener(window,"contextmenu",this._bindRunDragEnd)}end(){this._isDragging=!1,this._offListener()}}exports.Drag=s;
//# sourceMappingURL=drag-CzE5R222.js.map
