Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/animation/animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ extension _AnimationControllerX on AnimationController {
Animation<Offset> swipeAnimation({
required Offset startPosition,
required Offset endPosition,
required Curve curve,
}) {
return Tween<Offset>(
begin: startPosition,
end: endPosition,
).animate(
CurvedAnimation(
parent: this,
curve: const Cubic(0.7, 1, 0.73, 1),
curve: curve,
),
);
}
Expand Down
10 changes: 10 additions & 0 deletions lib/src/swipable_stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SwipableStack extends StatefulWidget {
this.allowVerticalSwipe = true,
Curve? cancelAnimationCurve,
Curve? rewindAnimationCurve,
Curve? swipeAnimationCurve,
this.swipeAnchor,
this.dragStartBehavior = DragStartBehavior.start,
this.hitTestBehavior = HitTestBehavior.deferToChild,
Expand All @@ -44,6 +45,8 @@ class SwipableStack extends StatefulWidget {
cancelAnimationCurve ?? _defaultCancelAnimationCurve,
rewindAnimationCurve =
rewindAnimationCurve ?? _defaultRewindAnimationCurve,
swipeAnimationCurve =
swipeAnimationCurve ?? _defaultSwipeAnimationCurve,
assert(0 <= viewFraction && viewFraction <= 1),
assert(0 <= horizontalSwipeThreshold && horizontalSwipeThreshold <= 1),
assert(0 <= verticalSwipeThreshold && verticalSwipeThreshold <= 1),
Expand Down Expand Up @@ -108,6 +111,9 @@ class SwipableStack extends StatefulWidget {
/// A curve to animate the card when rewinding the swipe.
final Curve rewindAnimationCurve;

/// default curve to animate the card when programatically swiping cards.
final Curve swipeAnimationCurve;

/// The [DragStartBehavior] of the swipes.
final DragStartBehavior dragStartBehavior;

Expand All @@ -134,6 +140,8 @@ class SwipableStack extends StatefulWidget {

static const _defaultStackClipBehaviour = Clip.hardEdge;

static final _defaultSwipeAnimationCurve = Cubic(0.7, 1, 0.73, 1);

static final _defaultCancelAnimationCurve = Sprung.custom(
damping: 17,
mass: 0.5,
Expand Down Expand Up @@ -669,6 +677,7 @@ class _SwipableStackState extends State<SwipableStack>
context: context,
swipeDirection: swipeDirection,
),
curve: widget.swipeAnimationCurve,
);

void animate() {
Expand Down Expand Up @@ -736,6 +745,7 @@ class _SwipableStackState extends State<SwipableStack>
context: context,
swipeDirection: swipeDirection,
),
curve: widget.swipeAnimationCurve,
);

void animate() {
Expand Down