Skip to content

Commit a6f271f

Browse files
Add automatic full expand animation to items
1 parent 994b969 commit a6f271f

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

core/src/components/item-sliding/item-sliding.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,34 +314,33 @@ export class ItemSliding implements ComponentInterface {
314314
try {
315315
// Calculate which options we're using
316316
const options = direction === 'end' ? this.rightOptions : this.leftOptions;
317-
const optsWidth = direction === 'end' ? this.optsWidthRightSide : this.optsWidthLeftSide;
318317

319-
// Phase 1: Reveal options beyond threshold to trigger expandable state
320-
// This sets the SwipeEnd or SwipeStart state which expands the expandable option
321-
const thresholdAmount = direction === 'end' ? optsWidth + SWIPE_MARGIN : -(optsWidth + SWIPE_MARGIN);
322-
this.setOpenAmount(thresholdAmount, false);
323-
324-
// Add AnimatingFullSwipe flag while preserving the SwipeEnd/SwipeStart state
325-
this.state = this.state | SlidingState.AnimatingFullSwipe;
318+
// Trigger expandable state without moving the item
319+
// Set state directly so expandable option fills its container, starting from
320+
// the exact position where the user released, without any visual snap.
321+
this.state =
322+
direction === 'end'
323+
? SlidingState.End | SlidingState.SwipeEnd | SlidingState.AnimatingFullSwipe
324+
: SlidingState.Start | SlidingState.SwipeStart | SlidingState.AnimatingFullSwipe;
326325

327326
await new Promise((resolve) => setTimeout(resolve, 100));
328327

329-
// Phase 2: Animate off-screen while maintaining the expanded state
328+
// Animate off-screen while maintaining the expanded state
330329
const offScreenDistance = direction === 'end' ? window.innerWidth : -window.innerWidth;
331330
await this.animateToPosition(offScreenDistance, 250);
332331

333-
// Phase 3: Trigger action
332+
// Trigger action
334333
if (options) {
335334
options.fireSwipeEvent();
336335
}
337336

338-
// Phase 4: Small delay before returning
337+
// Small delay before returning
339338
await new Promise((resolve) => setTimeout(resolve, 300));
340339

341-
// Phase 5: Return to closed state
340+
// Return to closed state
342341
await this.animateToPosition(0, 250);
343342

344-
// Phase 6: Reset state
343+
// Reset state
345344
if (this.item) {
346345
this.item.style.transition = '';
347346
}

core/src/components/item-sliding/test/full-swipe/index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ <h2>Mixed Scenarios</h2>
9696
// Log swipe events for debugging
9797
document.querySelectorAll('ion-item-sliding').forEach((item) => {
9898
const id = item.getAttribute('id');
99-
const options = item.querySelectorAll('ion-item-option');
100-
options.forEach((option) => {
101-
option.addEventListener('ionSwipe', () => {
102-
console.log(`[${id}] ionSwipe event fired for:`, option.textContent);
99+
item.querySelectorAll('ion-item-options').forEach((options) => {
100+
options.addEventListener('ionSwipe', () => {
101+
console.log(`[${id}] ionSwipe fired on ${options.getAttribute('side')} side`);
103102
});
104103
});
105104
});

0 commit comments

Comments
 (0)