johnny / johnny/jquery-sortable

Distance search performance

Open
#129 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
1.5k
Forks
429
PR merge metrics
No merged PRs in 30d

Description

Hey,
Thanks for this awesome plugin :).
i have the issue when the list become too big e.g. > 100 and im trying to enhance the performance of it:

```
function sortByDistanceDesc(dimensions, pointer, lastPointer) {
pointer = [pointer.left, pointer.top]
lastPointer = lastPointer && [lastPointer.left, lastPointer.top]

var dim,
i = dimensions.length,
distances = []

while(i--){
dim = dimensions[i];
distances[i] = [i,d(dim,pointer), lastPointer && d(dim, lastPointer)];
}

distances = distances.sort(function (a,b) {
return b[1] - a[1] || b[2] - a[2] || b[0] - a[0]
})

// last entry is the closest
return distances
}
```

this function become costly while dragging the item because its called to calculate the nearest element in the list and its slow when the list is big, do you have any idea how to enhance it?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.