Skip to content

Commit dbd417c

Browse files
fixed #713 (#761)
1 parent 2b9ec88 commit dbd417c

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

docs/html5sortable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ var sortable = (function () {
12691269
return;
12701270
}
12711271
var options = addData(sortableElement, 'opts');
1272-
if (parseInt(options.maxItems) && filter(sortableElement.children, addData(sortableElement, 'items')).length >= parseInt(options.maxItems) && dragging.parentElement !== sortableElement) {
1272+
if (parseInt(options.maxItems) && filter(sortableElement.children, addData(sortableElement, 'items')).length > parseInt(options.maxItems) && dragging.parentElement !== sortableElement) {
12731273
return;
12741274
}
12751275
e.preventDefault();

docs/index.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h2 class="h3 m0">
5050
<div class="px2 muted">
5151
forcePlaceholderSize: true,<br />
5252
placeholderClass: 'ph-class', <br />
53-
hoverClass: 'bg-maroon yellow' <br />
53+
hoverClass: 'bg-maroon yellow', <br />
5454
</div>
5555
<div>});</div>
5656
</code>
@@ -63,7 +63,6 @@ <h2 class="h3 m0">
6363
<li class="p1 mb1 navy bg-yellow" style="position: relative; z-index: 10">Item 3</li>
6464
<li class="p1 mb1 navy bg-yellow" style="position: relative; z-index: 10">Item 4</li>
6565
<li class="p1 mb1 navy bg-yellow" style="position: relative; z-index: 10">Item 5</li>
66-
<li class="p1 mb1 navy bg-yellow" style="position: relative; z-index: 10">Item 6</li>
6766
</ul>
6867
<button class="ml4 js-serialize-button button navy bg-yellow">Serialize</button>
6968
<script type="text/javascript">
@@ -424,6 +423,7 @@ <h2 class="h3 m0">Sortable Copy</h2>
424423
<code class="mb0">
425424
<div>sortable('.o-sortable', {</div>
426425
<div class="px2 muted">copy:true // default to false</div>
426+
<div class="px2 muted">maxItems: 2</div>
427427
<div>});</div>
428428
</code>
429429
</div>
@@ -452,9 +452,10 @@ <h2 class="h4 mt1">Copy items here</h2>
452452
placeholderClass: 'mb1 bg-navy border border-yellow',
453453
});
454454
sortable('.js-sortable-copy-target', {
455-
forcePlaceholderSize: true,
455+
forcePlaceholderSize: true,
456456
acceptFrom: '.js-sortable-copy,.js-sortable-copy-target',
457-
placeholderClass: 'mb1 border border-maroon',
457+
placeholderClass: 'mb1 border border-maroon',
458+
maxItems: 2
458459
});
459460
sortable('.js-grid', {
460461
forcePlaceholderSize: true,

src/html5sortable.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ export default function sortable (sortableElements, options: configuration|objec
634634
return
635635
}
636636
const options = data(sortableElement, 'opts')
637-
if (parseInt(options.maxItems) && filter(sortableElement.children, data(sortableElement, 'items')).length >= parseInt(options.maxItems) && dragging.parentElement !== sortableElement) {
637+
if (parseInt(options.maxItems) && filter(sortableElement.children, data(sortableElement, 'items')).length > parseInt(options.maxItems) && dragging.parentElement !== sortableElement) {
638638
return
639639
}
640640
e.preventDefault()

0 commit comments

Comments
 (0)