Skip to content

Latest commit

 

History

History
110 lines (72 loc) · 2.89 KB

File metadata and controls

110 lines (72 loc) · 2.89 KB

Basic Usage

This guide explains the basic features of CardStackView: Swipe, Rewind, and Cancel.

Swipe

Manual Swipe

Users can swipe cards by dragging in the configured direction:

ManualSwipe

Swipe directions are configured via setDirections():

manager.setDirections(Direction.HORIZONTAL)  // Left/Right
manager.setDirections(Direction.VERTICAL)     // Top/Bottom
manager.setDirections(Direction.FREEDOM)      // All directions

Automatic Swipe

You can swipe cards programmatically:

cardStackView.swipe()

AutomaticSwipe

Custom Swipe Animation

You can customize the swipe animation:

val setting = SwipeAnimationSetting.Builder()
    .setDirection(Direction.Right)
    .setDuration(Duration.Normal.duration)
    .setInterpolator(AccelerateInterpolator())
    .build()
manager.setSwipeAnimationSetting(setting)
cardStackView.swipe()

See Custom Animations for more details.

Cancel

If a card is dragged less than the configured threshold, the swipe is canceled and the card springs back:

Cancel

The threshold is configured via setSwipeThreshold():

manager.setSwipeThreshold(0.3f)  // 30% - Default

See Configuration for more details.

Rewind

Rewind brings back the last swiped card:

Rewind

Programmatic

cardStackView.rewind()

Custom Rewind Animation

You can customize the rewind animation:

val setting = RewindAnimationSetting.Builder()
    .setDirection(Direction.Bottom)
    .setDuration(Duration.Normal.duration)
    .setInterpolator(DecelerateInterpolator())
    .build()
manager.setRewindAnimationSetting(setting)
cardStackView.rewind()

See Custom Animations for more details.

Manual Rewind Gestures

You can also configure gestures for rewind. See Advanced Features.

Swipeable Method

You can control how swiping can be performed:

manager.setSwipeableMethod(SwipeableMethod.AutomaticAndManual)  // Both
manager.setSwipeableMethod(SwipeableMethod.Automatic)            // Code only
manager.setSwipeableMethod(SwipeableMethod.Manual)              // Gestures only
manager.setSwipeableMethod(SwipeableMethod.None)                // Disabled

See Configuration for more details.

Next Steps