Skip to content

Commit

Permalink
feat(draggable): allow ignore_dragging config option to be a function
Browse files Browse the repository at this point in the history
  • Loading branch information
vieron committed Mar 26, 2014
1 parent f1ad03c commit 69fcfe4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/jquery.draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limit: true,
offset_left: 0,
autoscroll: true,
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'],
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'], // or function
handle: null,
container_width: 0, // 0 == auto
move_element: true,
Expand Down Expand Up @@ -387,6 +387,10 @@
return !$(event.target).is(this.options.handle);
}

if ($.isFunction(this.options.ignore_dragging)) {
return this.options.ignore_dragging(event);
}

return $(event.target).is(this.options.ignore_dragging.join(', '));
};

Expand Down

2 comments on commit 69fcfe4

@hrosenbauer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature doesn't work.
ignore_dragging has always the default values - maybe it has to do with how the options are initialized:

var draggable_options = $.extend(true, {}, this.options.draggable, {
    ...
});

Shouldn't it be the other way around?

var draggable_options = $.extend(true, {}, {
    ...
}, this.options.draggable);

Example: http://jsbin.com/fuwunuyi/4/edit

@vieron
Copy link
Member Author

@vieron vieron commented on 69fcfe4 Jun 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! You are right!

We are using ignore_dragging only with Draggable and I forgot to check compatibility with Gridster.

There are some Draggable options (start, stop, drag, offset_left...) defined inside Gridster that can not be overwriten to ensure Gridster works correctly. This is the reason why options are initialized in "reverse" order.

I've just pushed 6bcfa6e that fixes the problem.

Thanks for the time you are taking contributing to gridster.js!! :D

Please sign in to comment.