Skip to content

Commit 176456d

Browse files
committed
Adding forcePlaceholderSize option, Fixes farhadi#7 (Thanks to @ooyes).
1 parent 2578770 commit 176456d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ $('.sortable').sortable({
4242
handle: 'h2'
4343
});
4444
```
45+
Setting `forcePlaceholderSize` option to true, forces the placeholder to have a height:
46+
47+
``` javascript
48+
$('.sortable').sortable({
49+
forcePlaceholderSize: true
50+
});
51+
```
4552

4653
Use `connectWith` option to create connected lists:
4754

jquery.sortable.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ $.fn.sortable = function(options) {
4141
var dt = e.originalEvent.dataTransfer;
4242
dt.effectAllowed = 'move';
4343
dt.setData('Text', 'dummy');
44-
dragging = $(this).addClass('sortable-dragging');
45-
index = dragging.index();
44+
index = (dragging = $(this)).addClass('sortable-dragging').index();
4645
}).on('dragend.h5s', function() {
4746
dragging.removeClass('sortable-dragging').fadeIn();
4847
placeholders.detach();
@@ -65,6 +64,9 @@ $.fn.sortable = function(options) {
6564
e.preventDefault();
6665
e.originalEvent.dataTransfer.dropEffect = 'move';
6766
if (items.is(this)) {
67+
if (options.forcePlaceholderSize) {
68+
placeholder.height(dragging.height());
69+
}
6870
dragging.hide();
6971
$(this)[placeholder.index() < $(this).index() ? 'after' : 'before'](placeholder);
7072
placeholders.not(placeholder).detach();

0 commit comments

Comments
 (0)