Get coordinates for first/last available position
See original GitHub issueHi, is it possible to upgrade the library with two additional methods to return coordinates of first available position and coordinates of last available position? Something like getFirstAvailablePostion() and getLastAvailablePostion(). getNextPossiblePosition() returns only if there is an available position, but not where it is. I’ve looked into source code, and I think that it could be done by modifying this code to:
for (; rowsIndex < this.rows; rowsIndex++) {
newItem.y = rowsIndex;
colsIndex = 0;
for (; colsIndex < this.columns; colsIndex++) {
newItem.x = colsIndex;
if (!this.checkCollision(newItem)) {
return [newItem.x, newItem.y]; // <- actual modification
}
}
}
For last item, newItem x and y could start with max values, and then decrement in for loops.
I would actually try to do and test this myself, but I’m noob and couldn’t figure out why this.options.api.getNextPossiblePosition({ ... }) throws an error (Object is possibly undefined) and won’t compile in the cloned repo.
Also, thanks for the library. It’s a life saver, and really easy to use.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
Ok will try to add last available position callback in version 5.0
Hi @petarGitNik , This feature was added in v4.7.0 Thanks to @NoMercy235