-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: sheet modal, add option to prefer scrolling when not fully expanded #24631
Comments
Thanks for the issue. This behavior is intentional and was designed to model how native iOS apps handle the sheet. Can you please explain why this behavior does not work for your use case? |
You are right, I have been looking at other apps and this is not a bug. I propose a new parameter to choose if you want to slide the content and slide the modal only from the header, or slide the modal without considering the content as it currently is. In my case, I have a map, with some items in the modal. Clicking on the item moves the map to the coordinates of the item. If I have the modal at 100% the movement is not seen, if I have the modal for example at 40%, I can't scroll through the list of items. |
Thanks! It sounds like in this case you want a swipeable modal that does not take up 100% of the screen. Would setting My concern is adding this functionality would make swiping up harder as it would limit where you can swipe to just the header. Additionally, if you chose not to use a header users would not be able to swipe at all. This is something the card-style modal does, but we are looking to change that since it has been a pain point for some. |
Yes, I had also thought of it as a solution, but in that case you could not put the modal at 100% of the screen, and it greatly limits the content you can see. In my example it's not that useful, but there may be other cases where you need 40% scrolling content as well as 100%. |
Thanks. Do you have any examples of native iOS/Android apps that provide the behavior you are looking to achieve? |
Hello, I have been able to see the behavior in the youtube Android application, in the long descriptions. I don't have an iphone to check it. video6039851876587932189.mp4 |
Hello @liamdebeasi, I have found a bug that has nothing to do with the petition we are talking about, but it coincides with the title :) When the ion-modal contains ion-header, the bottom part of the ion-content cannot be read at all. https://stackblitz.com/edit/ionic-angular-v5-axhw6t?file=src%2Fapp%2Fapp.component.html |
@Marius-Romanus I believe that specific side-issue has been reported here: #24706 and PR to address it here: #24723 |
Native iOS has this feature according to https://sarunw.com/posts/bottom-sheet-in-ios-15-with-uisheetpresentationcontroller/, so I think we should add it in Ionic as well. |
+1 Looking for a way to make content inside sheet modal scrollable even when its not 100% |
It works perfectly for me, and on the ion-content in my component. Make sure you've declared your directive in a common module, and imported that into your common components module too. It took a minute to get mine working as this was the first directive in the app so I didn't have some of the modules setup yet. |
for react, maybe the following code will help you,give a ref attribute to the element you want to scroll,and then like code write in useEffect, make it stopPropagation.
|
@molleahahs Thanks for that code! I am still getting this problem despite having e.stopPropagation() fire on modal touch events unfortunately. Would love to see this option built in to ionic soon. |
Found a way to make the modal sheet scrollable no matter on what breakpoint by reverse engineering the CSS that is applied by the ion-modal ion-content::part(scroll) {
overflow-y: var(--overflow);
overscroll-behavior-y: contain;
} |
still waiting for the feature |
Would also love to see this feature. |
I'd love this feature. Ideally it would align with Apple's native behavior, in which a swipe within modal content starts by scrolling, until we reach the top of scrollable content, at which point it turns into a drag action on the entire sheet and ultimately a dismissal if swiped to the bottom of the screen. Or, in fewer words: You can scroll and dismiss in the same gesture. In the meantime I thought I'd share a workaround that I cobbled together from this thread and some SO sources. This doesn't provide what I just described—a swipe only scrolls, it can't drag or dismiss (unless you target the drag handle, in which case it's not a scroll). Basically I declare the breakpoint to be In my global scss file: /**
HOW TO USE:
* Give your modal `[initialBreakpoint]="1"` and `[breakpoints]="[0, 1]"`. If you include other breakpoints
in the array, scrolling will not work on them. By calling the breakpoint 1, ionic provides the scrolling.
* Give your modal class `scrollable-sheet-modal-95`. This will take up 95% of the screen height. Rather
than hardcode this, the mixin below parses the "-95" suffix.
* If you'd like a different percentage, duplicate the "@include" line below with a new argument and use
a corresponding class, e.g. `@include custom-sheet-modal-height(90)` and `sfd-scrollable-sheet-modal-90`.
You can't just use any suffix you want in the class; there has to be a matching "@include".
* But if you want a much lower height, maybe question why you're making it scrollable rather than making
it bigger.
*/
@mixin custom-sheet-modal-height($argument) {
$heightString: $argument;
&-#{$heightString}::part(content) {
height: unquote($argument + '%');
bottom: unquote('-' + (100 - $argument) / 2 + '%');
}
}
ion-modal.scrollable-sheet-modal {
position: relative;
@include custom-sheet-modal-height(95);
// Add similar lines here to use other heights. Like:
// @include custom-sheet-modal-height(90);
} |
I would like this feature too, I have the same issue. |
up |
I implemented a solution in Vue since i wanted the same behaviour as @andybonner:
Hope it helps somebody! Template<ion-content ref="content" :fullscreen="true" :scrollEvents="true" @ionScroll="on_scroll($event)"> Scriptlet content = ref(null)
let content_scroll_start = ref(null)
let content_scroll_top = ref(null)
let content_scroll_start_from_top = ref(false)
let timer = ref(null)
let timer_timestamp = ref(null)
onMounted(async () => {
content.value.$el.addEventListener("touchstart", on_native_scroll_start)
content.value.$el.addEventListener("touchmove", on_native_scroll)
})
function on_native_scroll_start(event) {
content_scroll_start.value = event
content_scroll_start_from_top.value = content_scroll_is_top.value ? true : false
}
async function on_native_scroll(event) {
let scroll = event.changedTouches[0]
if (scroll.screenY - content_scroll_start.value.changedTouches[0].screenY > 0) {
if (!content_scroll_is_top.value || !content_scroll_start_from_top.value) return
if (timer.value || timer_timestamp.value === content_scroll_start.value.timeStamp) return
timer.value = setTimeout(async () => {
const modal = await modalController.getTop()
const current_breakpoint = await modal.getCurrentBreakpoint()
if (current_breakpoint === 1) modal.setCurrentBreakpoint(0.65)
clearTimeout(timer.value)
timer.value = null
timer_timestamp.value = content_scroll_start.value.timeStamp
}, 50)
} else if (scroll.screenY - content_scroll_start.value.changedTouches[0].screenY < 0) {
if (timer.value) clearTimeout(timer.value)
}
}
function on_scroll(event) {
// prettier-ignore
const { detail: { scrollTop } } = event
content_scroll_top.value = scrollTop
}
const content_scroll_is_top = computed(() => {
return content_scroll_top.value <= 0 || content_scroll_top.value === null
}) Resources |
Would also like to see the iOS native way of scroll and swipe to next breakpoint with same gesture. Like Apple Maps. Now it’s very hard to close it when the modal sheet is fully opened. |
Can you attach a video of this? What you're describing sounds different than what is described in the original post. |
Still waiting for this feature |
@liamdebeasi The video for scrolling and dragging the Sheet in Apple Maps with 1 gesture: RPReplay_Final1700683167.1.mp4 |
That's a different behavior and not something that will be solved by this feature. This feature is focused on allowing the content to scroll even when the sheet modal is not fully expanded. We have a similar request for this in #23919, but we are unable to add it due to platform limitations. The way browsers handle scroll dispatching does not make this functionality possible at the moment. The linked thread has more context. |
Aaah, that's indeed different. Thank you for the great answer. |
Hi @leonkosterss , The modal is still resizable? I'm looking for this behaviour. Can you help me out? |
Need this behaviour too. Have tried all the workarounds on this page but can't get any of them working - is there a complete solution anywhere? This is really necessary for my project. |
I achieved this behavior in my project using Ionic Gestures in a standard
div with z-index above all other elements.
Em qua., 24 de jan. de 2024 às 20:56, Joel Utting ***@***.***>
escreveu:
… Need this behaviour too. Have tried all the workarounds on this page but
can't get any of them working - is there a complete solution anywhere? This
is really necessary for my project.
—
Reply to this email directly, view it on GitHub
<#24631 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQWSQPPFDJUSB5VCSQCTLIDYQGUUZAVCNFSM5MT3QYRKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJQHEYTOMBTGE4Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
+1 also would love to see this feature soon 🔥 |
+1 also here |
+1 |
1 similar comment
+1 |
Would love this feature :) |
+1 |
It's absolutely ridiculous that this is still an issue in 2024. Devs pls do something. |
Any update in 2024 ? (T_T) |
Prerequisites
Ionic Framework Version
Current Behavior
Hi, in the Sheet Modal the scroll of the content doesn't appear unless it's at 100% size, in other breakpoints the scroll doesn't appear.
Expected Behavior
The scroll must adjust to the content at all times, regardless of the breakpoint.
Steps to Reproduce
Code Reproduction URL
No response
Ionic Info
Ionic:
Ionic CLI : 6.18.1
Utility:
cordova-res : not installed globally
native-run : 1.5.0
System:
NodeJS : v17.3.0
npm : 8.3.0
OS : Windows 10
Additional Information
No response
The text was updated successfully, but these errors were encountered: