(props: SheetBackdropProps)
| 1012 | }); |
| 1013 | |
| 1014 | function useSwipeAnimation(props: SheetBackdropProps) { |
| 1015 | let {swipeDirection, snapPoints, index, isEntering, isExiting} = |
| 1016 | useContext(InternalSheetContext)!; |
| 1017 | let {viewRange, viewDirection, viewIterations} = getSwipeConfig(swipeDirection); |
| 1018 | |
| 1019 | if (props.swipeAnimation) { |
| 1020 | let rangeStart = |
| 1021 | props.swipeAnimationRange?.start != null |
| 1022 | ? toLength(snapPoints?.[props.swipeAnimationRange.start] ?? '0%') |
| 1023 | : '0%'; |
| 1024 | let rangeEnd = |
| 1025 | props.swipeAnimationRange?.end != null |
| 1026 | ? toLength(snapPoints?.[props.swipeAnimationRange.end] ?? '100%') |
| 1027 | : '100%'; |
| 1028 | if (swipeDirection === 'top' || swipeDirection === 'left') { |
| 1029 | rangeStart = `calc(100% - ${rangeStart})`; |
| 1030 | rangeEnd = `calc(100% - ${rangeEnd})`; |
| 1031 | [rangeStart, rangeEnd] = [rangeEnd, rangeStart]; |
| 1032 | } |
| 1033 | |
| 1034 | // TODO: fix cover with range |
| 1035 | |
| 1036 | if (supportsViewTimeline) { |
| 1037 | return { |
| 1038 | animationName: props.swipeAnimation, |
| 1039 | animationTimeline: `--sheet-timeline-${index}`, |
| 1040 | animationDirection: viewDirection, |
| 1041 | animationIterationCount: viewIterations, |
| 1042 | animationFillMode: 'both', |
| 1043 | animationRange: `${viewRange} ${rangeStart} ${viewRange} ${rangeEnd}`, |
| 1044 | animationTimingFunction: 'linear', |
| 1045 | animationComposition: 'replace' |
| 1046 | }; |
| 1047 | } else if (isEntering || isExiting) { |
| 1048 | // Fallback for Firefox, which doesn't support view timelines. |
| 1049 | return { |
| 1050 | animationName: props.swipeAnimation, |
| 1051 | animationDirection: isExiting ? 'reverse' : 'normal', |
| 1052 | animationDuration: '300ms', |
| 1053 | animationIterationCount: '1', |
| 1054 | animationFillMode: 'both', |
| 1055 | animationTimingFunction: 'linear', |
| 1056 | animationComposition: 'replace' |
| 1057 | }; |
| 1058 | } |
| 1059 | } |
| 1060 | |
| 1061 | return {}; |
| 1062 | } |
| 1063 | |
| 1064 | export interface SheetContentProps extends Omit<DialogProps, 'className' | 'isEntering'> { |
| 1065 | /** |
no test coverage detected