From 179690646fafe0a5f25a3061596e6e29bc8f8e17 Mon Sep 17 00:00:00 2001 From: nikita Date: Mon, 9 Nov 2015 16:43:44 +0500 Subject: [PATCH 1/2] bug with position sv-helper on bootstrap modal. --- src/angular-sortable-view.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/angular-sortable-view.js b/src/angular-sortable-view.js index aadbbb9..e66e50c 100644 --- a/src/angular-sortable-view.js +++ b/src/angular-sortable-view.js @@ -445,8 +445,18 @@ if(targetLeft + helperRect.width > containmentRect.left + body.scrollLeft + containmentRect.width) // right boundary targetLeft = containmentRect.left + body.scrollLeft + containmentRect.width - helperRect.width; } - this.style.left = targetLeft - body.scrollLeft + 'px'; - this.style.top = targetTop - body.scrollTop + 'px'; + + var add_left = 0; + var add_top = 0; + + var modal_offset = $('.modal-dialog').offset(); + if (typeof modal_offset != 'undefined') { + add_left = -(modal_offset.left); + add_top = -(modal_offset.top); + } + + this.style.left = targetLeft - body.scrollLeft + add_left + 'px'; + this.style.top = targetTop - body.scrollTop + add_top+ 'px'; }; var pointerOffset = { From 446e4b6a550c84d9b1d35b9c2e4fd2a75bf7f8df Mon Sep 17 00:00:00 2001 From: nikita Date: Mon, 9 Nov 2015 16:58:59 +0500 Subject: [PATCH 2/2] Don't include body.scroll to position, then sv-helper drawed inside bootstrap.modal --- src/angular-sortable-view.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/angular-sortable-view.js b/src/angular-sortable-view.js index e66e50c..226e68b 100644 --- a/src/angular-sortable-view.js +++ b/src/angular-sortable-view.js @@ -448,15 +448,21 @@ var add_left = 0; var add_top = 0; - + + var scrl_left = 0; + var scrl_top = 0; + var modal_offset = $('.modal-dialog').offset(); if (typeof modal_offset != 'undefined') { add_left = -(modal_offset.left); add_top = -(modal_offset.top); + } else { + scrl_left = body.scrollLeft; + scrl_top = body.scrollTop; } - this.style.left = targetLeft - body.scrollLeft + add_left + 'px'; - this.style.top = targetTop - body.scrollTop + add_top+ 'px'; + this.style.left = targetLeft - scrl_left + add_left + 'px'; + this.style.top = targetTop - scrl_top + add_top+ 'px'; }; var pointerOffset = {