mirror of
https://github.com/go-vikunja/app
synced 2024-06-01 02:06:51 +00:00
22 lines
526 B
Dart
22 lines
526 B
Dart
import 'dart:math';
|
|
|
|
double calculateItemPosition({double? positionBefore, double? positionAfter}) {
|
|
// only
|
|
if (positionBefore == null && positionAfter == null) {
|
|
return 0;
|
|
}
|
|
|
|
// first
|
|
if (positionBefore == null && positionAfter != null) {
|
|
return positionAfter / 2;
|
|
}
|
|
|
|
// last
|
|
if (positionBefore != null && positionAfter == null) {
|
|
return positionBefore + pow(2.0, 16.0);
|
|
}
|
|
|
|
// in the middle (positionBefore != null && positionAfter != null)
|
|
return (positionBefore! + positionAfter!) / 2;
|
|
}
|