diff --git a/package-lock.json b/package-lock.json index aa3832f9..e8a06be9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3146,6 +3146,16 @@ "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bl": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", @@ -6437,6 +6447,13 @@ "flat-cache": "^3.0.4" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true + }, "filesize": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz", @@ -9345,6 +9362,13 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "nan": { + "version": "2.14.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", + "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==", + "dev": true, + "optional": true + }, "nanoid": { "version": "3.1.20", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", @@ -20519,7 +20543,11 @@ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "dev": true, - "optional": true + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } }, "glob-parent": { "version": "3.1.0", diff --git a/src/BottomSheet.tsx b/src/BottomSheet.tsx index b26789f8..d2884da4 100644 --- a/src/BottomSheet.tsx +++ b/src/BottomSheet.tsx @@ -66,7 +66,6 @@ export const BottomSheet = React.forwardRef< // Before any animations can start we need to measure a few things, like the viewport and the dimensions of content, and header + footer if they exist const { ready, registerReady } = useReady() - const dismissable = !!onDismiss // Controls the drag handler, used by spring operations that happen outside the render loop in React const canDragRef = useRef(false) @@ -438,12 +437,27 @@ export const BottomSheet = React.forwardRef< } let newY = down - ? rubberbandIfOutOfBounds( - rawY, - onDismiss ? 0 : minSnapRef.current, - maxSnapRef.current, - 0.55 - ) + ? // @TODO figure out a better way to deal with rubberband overshooting if min and max have the same value + !onDismiss && minSnapRef.current === maxSnapRef.current + ? rawY < minSnapRef.current + ? rubberbandIfOutOfBounds( + rawY, + minSnapRef.current, + maxSnapRef.current * 2, + 0.55 + ) + : rubberbandIfOutOfBounds( + rawY, + minSnapRef.current / 2, + maxSnapRef.current, + 0.55 + ) + : rubberbandIfOutOfBounds( + rawY, + onDismiss ? 0 : minSnapRef.current, + maxSnapRef.current, + 0.55 + ) : predictedY if (first) { @@ -489,7 +503,7 @@ export const BottomSheet = React.forwardRef< {...props} data-rsbs-root data-rsbs-is-blocking={blocking} - data-rsbs-is-dismissable={dismissable} + data-rsbs-is-dismissable={!!onDismiss} data-rsbs-has-header={!!header} data-rsbs-has-footer={!!footer} className={className}