Skip to content

Adds containment option to sortable plugin. #939

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/plugins/sortable/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ QueryBuilder.define('sortable', function(options) {
var ghost;
var src;
var moved;
var containment = $(options.containment || document.body);

// Init drag and drop
this.on('afterAddRule afterAddGroup', function(e, node) {
Expand Down Expand Up @@ -73,8 +74,8 @@ QueryBuilder.define('sortable', function(options) {
},
onmove: function(event) {
// make the ghost follow the cursor
ghost[0].style.top = event.clientY - 15 + 'px';
ghost[0].style.left = event.clientX - 15 + 'px';
ghost[0].style.top = event.clientY - containment.offset().top - 15 + 'px';
ghost[0].style.left = event.clientX - containment.offset().left - 15 + 'px';
},
onend: function(event) {
// starting from Interact 1.3.3, onend is called before ondrop
Expand Down