Skip to content
Open
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
8 changes: 6 additions & 2 deletions addon/services/drag-coordinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import { isEqual } from '@ember/utils';


function indexOf(items, a) {
return items.findIndex(function (element) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianpetzer Interesting that the findIndex didn't work in your case. I guess the hasMany proxy array doesn't implement this function.

return isEqual(element, a);
var returnIndex=null;
items.forEach(function(element, index) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianpetzer This seems ok, but it doesn't break when it finds an item like the findIndex does. If you use a "for in" you can break sooner. That will make for more performant code.

https://stackoverflow.com/questions/2641347/short-circuit-array-foreach-like-calling-break

if (isEqual(element, a)) {
returnIndex=index;
}
});
return returnIndex;
}

function swapInPlace(items, a, b) {
Expand Down