Comments (11)
I use snapTo() function into onClose to reopen the sheet and this works for me
Exemple:
import { FC, useRef } from 'react';
import Sheet, { SheetRef } from 'react-modal-sheet';
import { SheetProps } from 'react-modal-sheet/src/types';
const ModalSheet:FC<SheetProps> = (props) => {
const ref = useRef<SheetRef>();
const snapTo = (i: number) => ref.current?.snapTo(i);
return (
<Sheet
isOpen
ref={ref}
snapPoints={[600, 400, 100]}
initialSnap={1}
onClose={()=>{snapTo(1)}}>
<Sheet.Container>
<Sheet.Content>
<div>content...</div>
</Sheet.Content>
</Sheet.Container>
</Sheet>
);
}
export default ModalSheet;
from react-modal-sheet.
If you swipe/drag down fast enough, in your example and when I tried to implement this, the sheet still closes. The work around I found was to set the sheet to close then reopen in onClose
from react-modal-sheet.
Anyone found a workaround for this? In my use case I have to keep the sheet open at all times, if the user tries to close it, then I have to show the Header so the user can open it up again.
from react-modal-sheet.
@txm3278 I believe this should already be possible with the current implementation: https://codesandbox.io/s/bitter-leaf-82cpv?file=/src/App.tsx
from react-modal-sheet.
Ah I see, I guess a prop like disableClosing
might be needed 🤔
I have to think about how this could be implemented and what does it mean for a sheet to be non-closable.
Eg. if you don't provide any snap points does it mean that the sheet should not be draggable at all when disableClosing
is true or does it just bounce back open if the user tries to close it via dragging down fast.
from react-modal-sheet.
@Temzasse I would second this issue because there are use-cases were you want to stop interacting (for some time) with the sheet itself:
- User opens the sheet
- User starts swiping an image gallery inside of it
Problem: Sheet shouldn't move or close in any case while swiping.
EDIT Maybe an elegant solution would be to support a "children
as a function" ("render props") approach passing some handlers
/actions
props to disable/enable certain functionality?
from react-modal-sheet.
@stephanschuber would the earlier mentioned disableClosing
solve your use case or should there also be a prop like disableInteractions
that would completely disable all gestures?
I think the disableClosing
prop should not disable all interactions in order to still have a nice UX with sheet (direct manipulation principle etc).
I believe that it should already be possible to have scrollable content inside the sheet in a way that the sheet doesn't move while scrolling. Take a look at the Scrollable example.
I'll try to find some time to tackle this issue this weekend.
from react-modal-sheet.
@Temzasse I had to remove the onDrag*
handlers while swiping to avoid moving the sheet (because you never stay exactly horizontally)
from react-modal-sheet.
@stephanschubert I have released v1.3.0 where I added a disabledClosing
prop that can be passed to the whole sheet or its subparts to disabled dragging.
I also created an example where dragging is disabled for the sheet content when the content is horizontally scrolled.
I hope that this solves your issues 🙂
I still need to think more about the initial issue of how to disable the closing of the sheet and what does it actually mean 🤔
from react-modal-sheet.
@Temzasse Yep, works for my use-case. Thanks 👍
from react-modal-sheet.
This feature request needs more information since it's not super clear what it means for the sheet to be forced open. There are userland solutions for this problem like described above so I'm going to close this issue for now but feel free to open a PR with a suggested solution 🙂
from react-modal-sheet.
Related Issues (20)
- Features for split pane
- `onClick` is missing from backdrop props HOT 2
- How can I keep the modal sheet opened using snap points?
- Iphone Keyboard Issue when we have input in content HOT 4
- Strange behaviour after screen orientation changes HOT 3
- framer-motion is not tree-shaking HOT 1
- Unable to scroll behind the sheet, but able to click HOT 1
- Scroll flickering on iOS with Sheet.Scroller & inputs HOT 4
- Spring type animation
- Sheet is not opening on mobile browsers
- Sheet is not reopening in desktop Chrome HOT 3
- Allow style with Tailwind with className prop HOT 2
- initialSnap -34px bug HOT 2
- How do I implement a sticky footer? HOT 1
- Customer Header breaks dragging behavior
- Stacking sheets HOT 1
- TypeError: undefined is not an object (evaluating 'scrollable.scrollTop') HOT 1
- prevent Closing component HOT 2
- Sheet not closing on mobile HOT 8
- Bug on Safari Mobile, when switching the address bar up
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-modal-sheet.