calculateMovingLeftOffset function
double
calculateMovingLeftOffset(
{ - required int sourceIndex,
- required int targetIndex,
- required double progress,
- required double totalWidth,
})
Implementation
double calculateMovingLeftOffset({
required int sourceIndex,
required int targetIndex,
required double progress,
required double totalWidth
}) {
var targetPosition = calculateLeftOffset(targetIndex, totalWidth);
var sourcePosition = calculateLeftOffset(sourceIndex, totalWidth);
var distance = (targetPosition - sourcePosition).abs();
var passedDistance = distance * progress;
return targetPosition > sourcePosition
? sourcePosition + passedDistance
: sourcePosition - passedDistance;
}