svelte-swipeout
Version:
iOS-style swipeable list component for Svelte 5 with delete animations and mobile-optimized touch handling
33 lines (32 loc) • 1.16 kB
JavaScript
// ============================================================================
// Default Values
// ============================================================================
export const DEFAULT_CONFIG = {
threshold: 40,
velocityThreshold: 0.3,
animationDuration: 300,
animationType: 'ease',
maxSwipeRatio: 1.2,
rubberBand: true,
rubberBandTension: 0.8,
closeOnOpen: true,
disabled: false,
hapticFeedback: false,
snapPoints: [0.5, 1],
keyboardNavigation: true,
preventScroll: true
};
// ============================================================================
// Type Guards
// ============================================================================
export function isSwipeDirection(value) {
return typeof value === 'string' && ['left', 'right', 'none'].includes(value);
}
export function isSwipeState(value) {
return (typeof value === 'string' &&
['idle', 'dragging', 'animating', 'open', 'closing'].includes(value));
}
export function isActionType(value) {
return (typeof value === 'string' &&
['default', 'destructive', 'primary', 'secondary'].includes(value));
}