Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var sortable = new Sortable(el, {
forceFallback: false, // ignore the HTML5 DnD behaviour and force the fallback to kick in

fallbackClass: "sortable-fallback", // Class name for the cloned DOM Element when using forceFallback
fallbackOnBody: false, // Appends the cloned DOM Element into the Document's Body
fallbackOnto: document.body, // Appends the cloned DOM Element to the specified element, defaults to current element
fallbackTolerance: 0, // Specify in pixels how far the mouse should move before it's considered as a drag.

dragoverBubble: false,
Expand Down
6 changes: 3 additions & 3 deletions src/Sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ function Sortable(el, options) {
touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
forceFallback: false,
fallbackClass: 'sortable-fallback',
fallbackOnBody: false,
fallbackOnto: el,
fallbackTolerance: 0,
fallbackOffset: {x: 0, y: 0},
// Disabled on Safari: #1571; Enabled on Safari IOS: #2244
Expand Down Expand Up @@ -716,7 +716,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
}

try {

if (document.selection) {
_nextTick(() => {
document.selection.empty();
Expand Down Expand Up @@ -867,7 +867,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
// Bug if using scale(): https://stackoverflow.com/questions/2637058
// Not being adjusted for
if (!ghostEl) {
let container = this.options.fallbackOnBody ? document.body : rootEl,
let container = this.options.fallbackOnto,
rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
options = this.options;

Expand Down
2 changes: 1 addition & 1 deletion st/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ for (var i = 0; i < nestedSortables.length; i++) {
new Sortable(nestedSortables[i], {
group: 'nested',
animation: 150,
fallbackOnBody: true,
fallbackOnto: document.body,
swapThreshold: 0.65
});
}
Expand Down
41 changes: 41 additions & 0 deletions tests/single-list-fallback.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="./style.css">
<style>
#fallback {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
</style>
</head>
<body>

<div class="list" id="list1">
<div>Item 1.1</div>
<div>Item 1.2</div>
<div>Item 1.3</div>
<div>Item 1.4</div>
<div>Item 1.5</div>
</div>

<div id="fallback" class="list">

</div>

<script src="../Sortable.js"></script>

<script type="text/javascript">
new Sortable(document.getElementById('list1'), {
forceFallback: true,
fallbackOnto: document.getElementById('fallback')
});
</script>

</body>
</html>