Skip to content

Commit 1009cb1

Browse files
committed
1 parent 07708fa commit 1009cb1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Sortable.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ function Sortable(el, options) {
353353
this.el = el; // root element
354354
this.options = options = Object.assign({}, options);
355355

356+
if (this.options.fallbackOnBody) {
357+
// backwards compatibility
358+
this.options.getFallbackParent = () => (document.body)
359+
}
356360

357361
// Export instance
358362
el[expando] = this;
@@ -390,6 +394,7 @@ function Sortable(el, options) {
390394
touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
391395
forceFallback: false,
392396
fallbackClass: 'sortable-fallback',
397+
getFallbackParent: null,
393398
fallbackOnBody: false,
394399
fallbackTolerance: 0,
395400
fallbackOffset: {x: 0, y: 0},
@@ -852,7 +857,8 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
852857
// Bug if using scale(): https://stackoverflow.com/questions/2637058
853858
// Not being adjusted for
854859
if (!ghostEl) {
855-
let container = this.options.fallbackOnBody ? document.body : rootEl,
860+
let fallbackParent = typeof this.options.getFallbackParent === 'function' ? this.options.getFallbackParent() : null
861+
let container = fallbackParent ?? rootEl,
856862
rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
857863
options = this.options;
858864

st/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ for (var i = 0; i < nestedSortables.length; i++) {
202202
new Sortable(nestedSortables[i], {
203203
group: 'nested',
204204
animation: 150,
205-
fallbackOnBody: true,
205+
getFallbackParent: () => (document.body),
206206
swapThreshold: 0.65
207207
});
208208
}

0 commit comments

Comments
 (0)