| @@ -86,20 +86,14 @@ | ||
| 86 | 86 | $this->save(); |
| 87 | 87 | return $this; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $newPosition = ($prevTask->position + $nextItem->position) / 2; | |
| 91 | - | |
| 92 | - // check if new position is already taken | |
| 93 | - $exist = $stageQuery | |
| 94 | - ->where('position', $newPosition) | |
| 95 | - ->where('id', '!=', $this->id) | |
| 96 | - ->first(); | |
| 97 | - | |
| 98 | - if ($exist) { | |
| 90 | + if ($nextItem->position - $prevTask->position < 0.02) { | |
| 99 | 91 | self::reIndexStagesPositions($this->toArray()); |
| 100 | 92 | return $this->moveToNewPosition($newIndex); |
| 101 | 93 | } |
| 94 | + | |
| 95 | + $newPosition = ($prevTask->position + $nextItem->position)/ 2; | |
| 102 | 96 | |
| 103 | 97 | $this->position = $newPosition; |
| 104 | 98 | $this->save(); |
| 105 | 99 | return $this; |