Creating a Bottom Sliding Menu in Ionic 2

Hey there! I'm working on something that might not fit the typical definition of a sliding menu. It's not for navigation purposes, but rather to house some data. My idea for this actually comes from Apple Maps:

https://i.stack.imgur.com/hL1RU.jpg

https://i.stack.imgur.com/aCo4V.jpg

What I'm aiming for is the ability to slide it up and down when needed, allowing users to scroll through the content as seen in the first picture. On top of that, I'm curious if there's a way to achieve that soft light/blur effect with a map?

Answer №1

There's a fantastic blog post by Josh Morony that delves into a topic closely related to this. You can check it out here. Here is the result:

https://i.stack.imgur.com/ocYeH.gif

If you're interested in exploring further, you can find the complete source code and instructions on how to use it here. The key components include:

Snippet of Component code:

import { Component, Input, ElementRef, Renderer } from '@angular/core';
// Other imports...

@Component({
  selector: 'content-drawer',
  templateUrl: 'content-drawer.html'
})
export class ContentDrawer {
  // Class content...
}

View structure:

<ion-content>
    <ng-content></ng-content>
</ion-content>

Relevant Styles:

.ios, .md {
    content-drawer {
        width: 100%;
        height: 100%;
        position: absolute;
        z-index: 10 !important;
        box-shadow: 0px -4px 22px -8px rgba(0,0,0,0.75);
    }
}

To integrate this component into your page, follow these steps:

In your HomePage file:

import { Component } from '@angular/core';
// Other imports...

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
    drawerOptions: any;

    constructor(public navCtrl: NavController) {
        // Initialize options for the drawer...
    }
}

Layout Structure:

<ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  Your content here.
  <p>
    Link to documentation: <a href="http://ionicframework.com/docs/v2">docs</a>
  </p>
</ion-content>

<content-drawer [options]="drawerOptions">
    <div class="content">
      Additional content.
      <p>
        More info available in the <a href="http://ionicframework.com/docs/v2">docs</a>.
      </p>
    </div>
</content-drawer>

Custom Styles:

.ios, .md {
    page-home {
        content-drawer {
            background-color: #34495e !important;
        }

        content-drawer .content {
            padding: 20px;
        }
    }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error message indicating a problem with global typings in Angular 2 when using Webpack is displayed

My project is utilizing angular 2 with webpack and during the setup process, I encountered Duplicate identifier errors when running the webpack watcher: ERROR in [default] /angular/typings/globals/node/index.d.ts:370:8 Duplicate identifier 'unescape& ...

Trouble occurs in the HTML code when trying to access a property from an inherited interface in Angular

Currently, I am working with Angular 17 and have encountered a specific query: In my project, there is an IDetails interface containing certain properties: export interface IDetails { summary: Summary; description: string; } Additionally, there is an ...

Combining subclasses in TypeScript

Do you need help with a tricky situation? ...

Errors occur when trying to utilize an enum as a generic type in Typescript that are not compatible

Take a look at the code snippet provided. The concept here is that I have different provider implementations that extend a base provider. Each provider requires a settings object that is an extension of a base settings object. Additionally, each provider c ...

Conceal the initial value in a dropdown menu in a React component

I've set up a codesandbox to demonstrate the issue (https://codesandbox.io/s/practical-flower-k6cyl?file=/src/App.tsx) Is there a way to prevent the "AGE" text (first option) in the select box from being selected again? It should only be visible when ...

Angular 12: How to detect when a browser tab is closing and implement a confirmation dialog with MatDialog

I have a scenario where I am checking if the browser tab is closed using the code below. It currently works with windows dialog, but I would like to incorporate MatDialog for confirmation instead. @HostListener('window:beforeunload', ['$eve ...

Typescript MUI Autocomplete: Can you specify the parameter type of the PaperComponents function?

If you use MUI's Autocomplete, there is a property called PaperCompomponent that allows you to pass your own react component. This property is a function with properties as a parameter, which can then be used to pass on to your custom component. In T ...

Creating a specialized Docker image for Angular 9 production deployment

I don't have much experience with frontend development, but I'm currently working on creating a Docker image for an Angular 9 application. Here's what I've tried: ARG NODE_VERSION=12.16.1 # stage - # 1 FROM node:${NODE_VERSION}-buster- ...

Name the Angular interpolation function with the (click) event

I have a JSON file that defines different dynamic buttons, but when I click on them, the function is not being called. Here's how my JSON file looks: export const liveButtonData = [ { title: 'My Name', function: 'getName()'} ...

I am currently running the most recent version of AngularFire2. Is there a way to revert back to the earlier version?

Encountering errors with the syntax of the old angularfire2 version while using the latest version (angularfire2 version 4.0.0) pushed me to consider downgrading to a lower version (angularfire2 version 2.0.0). Is there a specific way to do this without ...

Disabling Immediate Row Checkbox in Angular Datatable Based on Column Data

Is there a way to prevent the checkbox in a row from being checked based on certain column data? In my datatable, I need to implement a condition where if firstname="Superman", then the checkbox for that particular row should be disabled to preve ...

Obtain the ViewContainerRef of the AppComponent

Currently, I am searching for a method to obtain the ViewContainerRef of the AppComponent using a service. I have come across various sources online such as this article, this blog post, and this forum thread, but they are all tailored to older versions o ...

Steps to trigger a modal using an effect and automatically close it upon receiving a specific dispatched action

Is there a better way to handle the closing of a dialog after a specific action is dispatched? Currently, I have a CalendarEventDeleteDialog with "yes" and "no" options. If the user selects "yes," a CalendarEventDeleteAction is dispatched followed by a Cal ...

What is the process for creating a PickByValue data type?

The TypeScript language comes with a built-in Pick type, which is defined as follows: type Pick<T, K extends keyof T> = { [P in K]: T[P]; }; If you were to create a custom PickByValue type, how would you implement it to achieve the following func ...

Tips for successfully mocking the AngularFire 2 service in a unit test

I am currently in the process of setting up unit tests for an Angular 2 application sample that utilizes AngularFire 2 authentication. The component I am working with is quite straightforward: import { Component } from '@angular/core'; import { ...

Create an interface that adheres to the defined mapped type

Working on a typescript project, I have defined the mapped type GlanceOsComparatorV2 interface DonutData { label: string; value: number; } interface ProjectMetric { value: number; } enum ZoneMetricId { ClickRate = 'clickRate', } enum Pa ...

Using RXJS within the pipe operator to make numerous HTTP requests

In my project, I have set up 3 API endpoints - candidates, vacancies, and interviews. { "candidates": [ { "id": 1, "name": "Serj" }, { "id": 2, "name": "Alex" } ], " ...

What is the process of integrating an API key into Apollo-Angular in order to retrieve information from the MongoDB Realm GraphQL API?

I have been utilizing the MongoDB realm GraphQL API to retrieve data, while also using Apollo-Angular. However, in order to access the data through the GraphQL API, an API key is required. I have successfully tested this by using Postman and including the ...

Is there a way to determine if there is history in Location.back in Angular 2 in order

I have a button that triggers Location.back(). I only want to show this button when there is history available. Is there a way to check if the location has any history, or if it can go back? Alternatively, is there a method for me to access the history my ...

Encountering a CORS issue when utilizing passport-facebook for Facebook authentication in my MEAN application

I'm currently working on implementing a Facebook login feature for my web app, built with express js, mongodb, and angular 2. The client-side of the app is generated using angular-cli (running on port 4200), and I'm utilizing the proxy config pr ...