Issue
I have a requirement to open the menu based on gesture from bottom as shown in below image GIF.
Here is what I'm able to achieve: Stackblitz
<template>
<ion-menu content-id="main-content">
<ion-header>
<ion-toolbar>
<ion-title>Menu Content</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<ion-menu-toggle>
<ion-button>Click to close the menu</ion-button>
</ion-menu-toggle>
</ion-content>
</ion-menu>
<ion-page id="main-content">
<ion-header>
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<ion-menu-toggle>
<ion-button>Click to open the menu</ion-button>
</ion-menu-toggle>
</ion-content>
</ion-page>
</template>
<script lang="ts">
import { IonButton, IonContent, IonHeader, IonMenu, IonMenuToggle, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
import { defineComponent } from 'vue';
export default defineComponent({
components: {
IonButton,
IonContent,
IonHeader,
IonMenu,
IonMenuToggle,
IonPage,
IonTitle,
IonToolbar,
},
});
</script>
Solution
You can use ionic sheet modal Docs:
<template>
<ion-header>
<ion-toolbar>
<ion-title>App</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<ion-button id="open-modal" expand="block">Open Sheet Modal</ion-button>
<ion-modal ref="modal" trigger="open-modal" :initial-breakpoint="0.25" :breakpoints="[0, 0.25, 0.5, 0.75]">
<ion-content class="ion-padding">
<ion-searchbar @click="$refs.modal.$el.setCurrentBreakpoint(0.75)" placeholder="Search"></ion-searchbar>
<ion-list>
<ion-item>
<ion-avatar slot="start">
<ion-img src="https://i.pravatar.cc/300?u=b"></ion-img>
</ion-avatar>
<ion-label>
<h2>Connor Smith</h2>
<p>Sales Rep</p>
</ion-label>
</ion-item>
<ion-item>
<ion-avatar slot="start">
<ion-img src="https://i.pravatar.cc/300?u=a"></ion-img>
</ion-avatar>
<ion-label>
<h2>Daniel Smith</h2>
<p>Product Designer</p>
</ion-label>
</ion-item>
<ion-item>
<ion-avatar slot="start">
<ion-img src="https://i.pravatar.cc/300?u=d"></ion-img>
</ion-avatar>
<ion-label>
<h2>Greg Smith</h2>
<p>Director of Operations</p>
</ion-label>
</ion-item>
<ion-item>
<ion-avatar slot="start">
<ion-img src="https://i.pravatar.cc/300?u=e"></ion-img>
</ion-avatar>
<ion-label>
<h2>Zoey Smith</h2>
<p>CEO</p>
</ion-label>
</ion-item>
</ion-list>
</ion-content>
</ion-modal>
</ion-content>
</template>
<script lang="ts" setup>
import {
IonButton,
IonModal,
IonHeader,
IonContent,
IonToolbar,
IonTitle,
IonItem,
IonList,
IonAvatar,
IonImg,
IonLabel,
IonSearchbar,
} from '@ionic/vue';
</script>
Answered By - Najam Us Saqib
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.