(props: SheetBackdropProps)
| 1034 | }); |
| 1035 | |
| 1036 | function useSwipeAnimation(props: SheetBackdropProps) { |
| 1037 | let {swipeDirection, snapPoints, timelineName, isEntering, isExiting} = |
| 1038 | useContext(InternalSheetContext)!; |
| 1039 | let {viewRange, viewDirection, viewIterations} = getSwipeConfig(swipeDirection); |
| 1040 | |
| 1041 | if (props.swipeAnimation) { |
| 1042 | let rangeStart = |
| 1043 | props.swipeAnimationRange?.start != null |
| 1044 | ? toLength(snapPoints?.[props.swipeAnimationRange.start] ?? '0%') |
| 1045 | : '0%'; |
| 1046 | let rangeEnd = |
| 1047 | props.swipeAnimationRange?.end != null |
| 1048 | ? toLength(snapPoints?.[props.swipeAnimationRange.end] ?? '100%') |
| 1049 | : '100%'; |
| 1050 | if (swipeDirection === 'top' || swipeDirection === 'left') { |
| 1051 | rangeStart = `calc(100% - ${rangeStart})`; |
| 1052 | rangeEnd = `calc(100% - ${rangeEnd})`; |
| 1053 | [rangeStart, rangeEnd] = [rangeEnd, rangeStart]; |
| 1054 | } |
| 1055 | |
| 1056 | // TODO: fix cover with range |
| 1057 | |
| 1058 | if (supportsViewTimeline) { |
| 1059 | return { |
| 1060 | animationName: props.swipeAnimation, |
| 1061 | animationTimeline: timelineName, |
| 1062 | animationDirection: viewDirection, |
| 1063 | animationIterationCount: viewIterations, |
| 1064 | animationFillMode: 'both', |
| 1065 | animationRange: `${viewRange} ${rangeStart} ${viewRange} ${rangeEnd}`, |
| 1066 | animationTimingFunction: 'linear', |
| 1067 | animationComposition: 'replace' |
| 1068 | }; |
| 1069 | } else if (isEntering || isExiting) { |
| 1070 | // Fallback for Firefox, which doesn't support view timelines. |
| 1071 | return { |
| 1072 | animationName: props.swipeAnimation, |
| 1073 | animationDirection: isExiting ? 'reverse' : 'normal', |
| 1074 | animationDuration: '300ms', |
| 1075 | animationIterationCount: '1', |
| 1076 | animationFillMode: 'both', |
| 1077 | animationTimingFunction: 'linear', |
| 1078 | animationComposition: 'replace' |
| 1079 | }; |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | return {}; |
| 1084 | } |
| 1085 | |
| 1086 | export interface SheetContentProps extends Omit<DialogProps, 'className' | 'isEntering'> { |
| 1087 | /** |
no test coverage detected