From 4a6f97d146d310ad19aeef7aa9231868b7921c17 Mon Sep 17 00:00:00 2001 From: Owen Farrugia Date: Tue, 10 Jan 2023 13:06:25 +0100 Subject: [PATCH] Removed deprication warnings, Updated docs, Removed bug fix from optional styles --- README.md | 1 + src/DragSelect.js | 41 ++++------------------------------------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 90064109..04808a23 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ Here are some properties for your convenience (not all): |onDragStartBegin |function |OPTIONAL. Fired when the user clicks in the area. This callback gets the event object. Executed **before** DragSelect function code runs | |onDragStart |function |OPTIONAL. Fired when the user clicks in the area. This callback gets the event object. Executed after DragSelect function code ran, befor the setup of event listeners | |onDragMove |function |OPTIONAL. Fired when the user drags. This callback gets the event object. Executed before DragSelect function code ran, after getting the current mouse position | +|onDragEnd |function |OPTIONAL. Fired when the user ends drag interaction. This callback gets the event object. Executed after DragSelect function code ran | |onElementSelect |function |OPTIONAL. Fired every time an element is selected. This callback gets a property which is the selected node | |onElementUnselect |function |OPTIONAL. Fired every time an element is de-selected. This callback gets a property which is the de-selected node | |callback |function |OPTIONAL. Callback function that gets fired when the selection is released. This callback gets a property which is an array that holds all selected nodes | diff --git a/src/DragSelect.js b/src/DragSelect.js index ae0cb801..f443d4f3 100644 --- a/src/DragSelect.js +++ b/src/DragSelect.js @@ -75,7 +75,7 @@ class DragSelect { */ constructor({ area = document, - autoScrollSpeed = 1, + autoScrollSpeed = 3, callback = () => { }, customStyles = false, hoverClass = 'ds-hover', @@ -249,11 +249,12 @@ class DragSelect { var selector = document.createElement('div'); selector.style.position = 'absolute'; + selector.style.display = 'none'; + selector.style.pointerEvents = 'none'; // fix for issue #8 (ie11+) + if (!this.customStyles) { selector.style.background = 'rgba(0, 0, 255, 0.1)'; selector.style.border = '1px solid rgba(0, 0, 255, 0.45)'; - selector.style.display = 'none'; - selector.style.pointerEvents = 'none'; // fix for issue #8 (ie11+) } var _area = this.area === document ? document.body : this.area; @@ -749,15 +750,6 @@ class DragSelect { * @return {('top'|'bottom'|'left'|'right'|false)} */ isCursorNearEdge(area, event) { - // @TODO DEPRECATION: remove support on next major release - if (typeof area === "object" && this._isElement(event)) { - console.warn("[DragSelect] DEPRECATION warning: this method signature is changing. From isCursorNearEdge(event, area) to isCursorNearEdge(area, event). Please use area as first argument and event as second. It will still work for now but functionality be removed soon") - const _event = event - const _area = area - area = _event - event = _area - } - var cursorPosition = this._getCursorPos(area, event); var areaRect = this._getAreaRect(area); @@ -1223,18 +1215,6 @@ class DragSelect { }; } - /** - * Returns the current x, y scroll value of a container - * If container has no scroll it will return 0 - * @param {(HTMLElement|SVGElement)} [area] - * @return {{x:number,y:number}} scroll X/Y - * @deprecated - */ - getScroll(area) { - console.warn('[DragSelect]: .getScroll is being deprecated soon. Please do not use it any longer. If you have a real use-case for this, please let us know at https://github.com/ThibaultJanBeyer/DragSelect') - return this._getScroll(area) - } - /** * Returns the current x, y scroll value of a container * If container has no scroll it will return 0 @@ -1262,19 +1242,6 @@ class DragSelect { return scroll; } - /** - * Returns the top/left/bottom/right/width/height - * values of a node. If Area is document then everything - * except the sizes will be nulled. - * @param {HTMLElement|SVGElement|any} area - * @returns {{top:number,left:number,bottom:number,right:number,width:number,height:number}} - * @deprecated - */ - getAreaRect(area) { - console.warn('[DragSelect]: .getAreaRect is being deprecated soon. Please do not use it any longer. If you have a real use-case for this, please let us know at https://github.com/ThibaultJanBeyer/DragSelect') - return this._getAreaRect(area) - } - /** * Returns the top/left/bottom/right/width/height * values of a node. If Area is document then everything