Skip to content

Commit 0d8ed3e

Browse files
committed
fix: prevent manual drag during animation when waitAnimationEnd is enabled
1 parent a10a9da commit 0d8ed3e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/FlashCards.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ const {
127127
getCardStyle,
128128
} = useStackTransform(() => ({ ...config.value }))
129129
130+
/**
131+
* Determines if drag should be disabled on cards
132+
*
133+
* Drag is disabled when:
134+
* - `disableDrag` prop is explicitly set to true
135+
* - `waitAnimationEnd` is enabled AND there are cards currently in transition
136+
* This prevents race conditions where a user can drag a new card while
137+
* the previous card is still animating, which causes cards to hang/freeze
138+
*/
139+
const isDragDisabled = computed(() => props.disableDrag || (config.value.waitAnimationEnd && hasCardsInTransition.value))
140+
130141
/**
131142
* Handles card swipe completion
132143
*/
@@ -215,6 +226,7 @@ defineExpose({
215226
v-bind="props"
216227
class="flashcards__card"
217228
:class="{ 'flashcards__card--active': itemId === currentItemId }"
229+
:disable-drag="isDragDisabled"
218230
@complete="(action, pos) => handleCardSwipe(itemId, action, pos)"
219231
@mounted="containerHeight = Math.max($event, 0)"
220232
@dragstart="emit('dragstart', item)"

0 commit comments

Comments
 (0)