提交 c3d724d8 编写于 作者: S Sebastian Rosengren

Knockout - Fixes #623 #585 #557

上级 4b9fc79d
......@@ -655,11 +655,11 @@ Link to the active instance.
```html
<!-- CDNJS :: Sortable (https://cdnjs.com/) -->
<script src="//cdnjs.cloudflare.com/ajax/libs/Sortable/1.4.0-rc1/Sortable.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/Sortable/1.4.2-rc1/Sortable.min.js"></script>
<!-- jsDelivr :: Sortable (http://www.jsdelivr.com/) -->
<script src="//cdn.jsdelivr.net/sortable/1.4.0-rc1/Sortable.min.js"></script>
<script src="//cdn.jsdelivr.net/sortable/1.4.2-rc1/Sortable.min.js"></script>
<!-- jsDelivr :: Sortable :: Latest (http://www.jsdelivr.com/) -->
......
......@@ -1258,6 +1258,6 @@
// Export
Sortable.version = '1.4.0';
Sortable.version = '1.4.2';
return Sortable;
});
此差异已折叠。
{
"name": "Sortable",
"main": "Sortable.js",
"version": "1.4.0",
"version": "1.4.2",
"homepage": "http://rubaxa.github.io/Sortable/",
"repo": "RubaXa/Sortable",
"authors": [
......
......@@ -78,7 +78,7 @@
moveItem(itemVM, removeOperation.collection, addOperation.collection, addOperation.event.clone, addOperation.event);
}
},
// Moves an item from the "to" collection to the "from" collection, these
// Moves an item from the "from" collection to the "to" collection, these
// can be references to the same collection which means it's a sort.
// clone indicates if we should move or copy the item into the new collection
moveItem = function (itemVM, from, to, clone, e) {
......@@ -89,11 +89,12 @@
originalIndex = fromArray.indexOf(itemVM),
newIndex = e.newIndex;
if (e.item.previousElementSibling)
{
newIndex = fromArray.indexOf(ko.dataFor(e.item.previousElementSibling));
if (originalIndex > newIndex)
newIndex = newIndex + 1;
// We have to find out the actual desired index of the to array,
// as this might be a computed array. We could otherwise potentially
// drop an item above the 3rd visible item, but the 2nd visible item
// has an actual index of 5.
if (e.item.previousElementSibling) {
newIndex = to().indexOf(ko.dataFor(e.item.previousElementSibling)) + 1;
}
// Remove sortables "unbound" element
......
......@@ -51,8 +51,8 @@
</ul>
</div>
<div class="col-1_2 mirror">
<h4>Sortable computed mirrored</h4>
<ul data-bind="foreach: sortableComputedItems">
<h4>Sortable underlaying computed</h4>
<ul data-bind="foreach: underlayingSortableComputedItems">
<li data-bind="text: name"></li>
</ul>
</div>
......@@ -101,7 +101,7 @@
<script src="../knockout-sortable.js"></script>
<script>
var sortableComputedItems = [{ name: 'Sortable computed 1' }, { name: 'Sortable computed 2' }, { name: 'Sortable computed 3' }];
var sortableComputedItems = [{ name: 'Sortable computed 1' }, { name: 'Filtered computed 2' }, { name: 'Sortable computed 3' }, { name: 'Filtered computed 4' }, { name: 'Sortable computed 5' }, { name: 'Filtered computed 6' }];
var sortableObservableItems = [{ name: 'Sortable observable 1' }, { name: 'Sortable observable 2' }, { name: 'Sortable observable 3' }];
var draggableComputedItems = [{ name: 'Draggable computed 1' }, { name: 'Draggable computed 2' }, { name: 'Draggable computed 3' }];
......@@ -113,7 +113,12 @@
underlayingDraggableComputedItems: ko.observableArray(draggableComputedItems),
draggableObservableItems: ko.observableArray(draggableObservableItems)
}
vm.sortableComputedItems = ko.computed(function () { return vm.underlayingSortableComputedItems(); });
vm.sortableComputedItems = ko.computed(function () {
return vm.underlayingSortableComputedItems()
.filter(function (item) {
return item.name.indexOf('Filtered') < 0;
});
});
vm.draggableComputedItems = ko.computed(function () { return vm.underlayingDraggableComputedItems(); });
ko.applyBindings(vm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册