startAnimation method
Start the rolling animation
Implementation
void startAnimation(bool isDraggingInSameRow) {
bool isSlideToRight = destinationIndex > sourceIndex;
bool isSlideToLeft = destinationIndex < sourceIndex;
TickerFuture? animationFuture;
if (isSlideToRight) {
/// slide to right, use 'reverse', offset.x: -1.0 -> 0.0
animationFuture = slideToLeftController.reverse(from: 1.0);
} else if (isSlideToLeft) {
/// slide to left, use 'reverse', offset.x: 1.0 -> 0.0
animationFuture = slideToRightController.reverse(from: 1.0);
}
/// dragging in the same row/line, just return
if (isDraggingInSameRow) return;
/// TODO ... Hit the first/last one, in this case animation effect issue ...
/// TODO ... Dragging one is the first/last one, in this case animation effect issue
/// stick a ghost for the last/first position element
if (isSlideToRight) {
if (element.isTheLastOne) {
setGhostType(GhostType.Next);
}
} else if (isSlideToLeft) {
if (element.isTheFirstOne) {
setGhostType(GhostType.Previous);
}
}
if (ghostType != GhostType.None) {
animationFuture?.then((value) {
setGhostType(GhostType.None);
});
}
}