Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Prevent drag from certains elements #1

Open
LrntL opened this issue Aug 25, 2022 · 1 comment
Open

[Feature] Prevent drag from certains elements #1

LrntL opened this issue Aug 25, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@LrntL
Copy link
Owner

LrntL commented Aug 25, 2022

Hi,

Thank you for your job on dragScroll.js.
This is exactly what I was looking for. 👍

I have a suggestion. According to my needs, I wanted to drag and scroll a large table element with multiple columns. These columns have inputs or button for making the table filterable or editable...

So I modified your plugin to add parameters to prevent scrolling by including/excluding a specific list of objects.

So line 23, I added options:

handle: null, // is or not (below selector)
selector: null // selectors

Line 81 (mousedown event) :

// Default drag is possible
var isDraggable = true;
var objTarget = $(e.target);
						
// Prevent dragging with unwanted selector
if (_handle == 'is' && !objTarget.is(_selector)) isDraggable = false;
						
// Prevent dragging with unwanted selector
if (_handle == 'not' && objTarget.is(_selector)) isDraggable = false;
						
// Is is draggable?
if (isDraggable) { ... [All mousedown code] ... }
Usage for dragging only with td or div with class Unicorn:

$('.myDraggableItem').dragScroll({ 
	direction: 'scrollLeft', 
	handle: 	'is', 
	selector: 	'td, div.Unicorn'
});

With that all other elements such as editable input are still usable because they are not locked by dragScroll functionnality.

Extra, in mousemove event to have a "move" cursor when dragging:

$this.css('cursor', 'move');

And so, in mouseup mouseleave event, to set back default cursor:

$this.css('cursor', 'default');

I hope you understood this and that it will help improving your work.
Thanks

@LrntL LrntL added the enhancement New feature or request label Aug 25, 2022
@LrntL
Copy link
Owner Author

LrntL commented Aug 25, 2022

This is the "issue" I posted on the original repo.
Theses modifications are included in the version I published here.

@LrntL LrntL pinned this issue Aug 25, 2022
Repository owner locked and limited conversation to collaborators Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant