Skip to content

Commit f19f14e

Browse files
committed
Simplify types
1 parent ab1f855 commit f19f14e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ export type Axis = 'x' | 'y';
22

33
export type ScrollDirection = 'left' | 'right' | 'up' | 'down';
44

5-
export type ScrollSnapAlignment = 'start' | 'end' | 'center';
5+
export type ScrollSnapAlignment = 'start' | 'end' | 'center' | 'none';
66

7-
export type ScrollSnapAlignValue = 'none' | ScrollSnapAlignment;
8-
9-
export type SnapPositionList = Record<ScrollSnapAlignment, number[]>;
7+
export type SnapPositionList = Record<Exclude<ScrollSnapAlignment, 'none'>, number[]>;
108

119
export function scrollSnapToNext( element: HTMLElement, direction: ScrollDirection, scrollToOptions: ScrollToOptions = { behavior: 'smooth' } ) {
1210

@@ -158,7 +156,7 @@ export function getSnapPositions( parent: HTMLElement, excludeOffAxis = true ):
158156

159157
const childStyle = window.getComputedStyle( child );
160158

161-
let [ childAlignY, childAlignX ] = childStyle.getPropertyValue( 'scroll-snap-align' ).split( ' ' ) as ScrollSnapAlignValue[];
159+
let [ childAlignY, childAlignX ] = childStyle.getPropertyValue( 'scroll-snap-align' ).split( ' ' ) as ScrollSnapAlignment[];
162160
if ( typeof childAlignX === 'undefined' ) {
163161
childAlignX = childAlignY;
164162
}

0 commit comments

Comments
 (0)