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

Challenges with Ionic 4 - Module '@angular/core/package.json' not found

Having some trouble with an Ionic 4 project code that works perfectly on my Mac but encounters an error when I try to run it on my Windows 10 PC. The specific error message states "Cannot find module '@angular/core/package.json'". Interestingly, ...

There was an unfortunate parsing failure in the module: An unexpected token appeared at position 4

I need help adding the FULLCALENDAR feature to my Angular v14 project. Despite going through all the necessary setup steps, I encountered an unexpected error. Can anyone provide guidance on how to resolve this issue? package.json "@fullcalendar/angul ...

Node.js: Handling Undefined Request Parameters

My get route is set up to receive two parameters "limit" and "page". router.get('/:limit/:page', userController.list); class UserController{ public list(req:Request, res:Response): void{ const limit:number = +req.params.limit || 25; ...

A step-by-step guide to customizing the Material UI Chips delete SVG icon to appear in white color through

Using a Material UI component, I added a custom class to my chip. Attached is a screenshot showing what I mean. Currently, I am attempting to change the color of the cross button to white. After inspecting the element, I discovered that it is an SVG ico ...

Setting up systemjs.config.js for utilizing relative paths within IIS - A step-by-step guide

My new ASP.NET MVC web application utilizes Angular for its UI components. I have set up the necessary config files in my project (e.g. package.json and systemjs.config.js). Created a test page Index.cshtml to test out the template in app.component.ts. The ...

What sets apart the typescript@latest and typescript@next NPM packages from each other?

Can you enlighten me on the disparities between typescript@next and typescript@latest? I understand the functionality of typescript@next, yet I struggle to differentiate it from typescript@latest. From my perspective, they appear to be identical. There is ...

Incorporate an image icon into an Angular grid

Currently, I am in the process of building a web application using Angular. The main goal is to create a grid and color specific cells based on data input. Below is the snippet of my HTML code: <mat-grid-list cols="10"> <mat-grid-tile * ...

Defining TypeScript class events by extending EventEmitter

I have a class that extends EventEmitter and is capable of emitting the event hello. How can I properly declare the on method with a specific event name and listener signature? class MyClass extends events.EventEmitter { emitHello(name: string): void ...

Challenges arise when working with Vue 3.2 using the <script setup> tag in conjunction with TypeScript type

Hey there! I've been working with the Vue 3.2 <script setup> tag along with TypeScript. In a simple scenario, I'm aiming to display a user ID in the template. Technically, my code is functioning correctly as it shows the user ID as expect ...

Guide on upgrading an Angular project to a targeted version with its corresponding dependencies

I'm embarking on reviving a previous angular venture. My objective is to bring it up-to-date with a particular version along with upgrading all its affiliated dependencies to the most recent ones. I attempted by initially uninstalling the CLI version, ...

Show a specific form field based on the chosen option in a dropdown menu using Angular and TypeScript

I am looking to dynamically display a form field based on the selected value from a dropdown list. For instance, if 'first' is chosen in the dropdown list, I want the form to remain unchanged. However, if 'two' is selected in the drop ...

What is the best way to import a data type from another file into a `.d.ts` file without converting it into a module?

Recently encountered a peculiar scenario involving d.ts files and namespaces. I have some d.ts files where I define and merge a namespace called PROJECT. Take a look at how it's declared and automatically merged (across multiple files) below: file1 ...

Guide to creating jest unit test for an observable variable exclusively utilized in a template resulting in the error "Property 'pipe' of undefined cannot be read"

Seeking help with creating unit tests for an Angular component that utilizes a constructor and observable variable in the HTML template. Below is the code snippet I am having issues with: voice-summary.component.ts export class VoiceSummaryComponent { v ...

Encountering issues in Angular 2 when attempting to pass data into root component through ng-content and binding. Objective: Creating a reusable form component

I currently have a .NET MVC application and I'm looking to integrate Angular 2 into it. The structure of my page is as follows: <html> <head>css imports and jquery imports</head> <body> <div> a bunch of table ...

The error message "Property 'name' does not exist on type 'User'" is encountered

When running this code, I expected my form to display in the browser. However, I encountered an error: Error: src/app/addproducts/addproducts.component.html:18:48 - error TS2339: Property 'price' does not exist on type 'ADDPRODUCTSComponent& ...

TypeScript requires that the `includes` function must have the same type parameter for both input and

When working with TypeScript, I've encountered an interesting dilemma regarding the use of the Array.Prototype.includes function. It seems that this function requires me to pass in the same type as in the original array, but isn't the purpose of ...

Exploring Angular: How to access ViewChild from a dynamically loaded component

One of my components includes a ViewChild element like this: @ViewChild('overView') content: ElementRef; I am dynamically loading this component in the following way: let overviewComponent = this.vcr.createComponent(OverviewComponent); let conte ...

Issue with the exported elements known as 'StatSyncFn'

My build is showing an error that I'm unable to identify the source or reason for. The error message looks like this... Error: node_modules/webpack-dev-middleware/types/index.d.ts:204:27 - error TS2694: Namespace '"fs"' has no expo ...

Oops! The mighty gulp-clean frowns upon attempts to eradicate files outside its domain

Whenever I execute the command: gulp clean I encounter an error even though I tried using: gulp clean --force but it didn't work. Could someone please clarify what might be causing this issue or what mistake I am making? Your help would be greatly ...

Differences between Angular services and exportsIn Angular,

I have a collection of straightforward tool functions that do not require sharing state across the application, do not need to be singleton instances, and do not rely on injected services. Is there any benefit to using an injectable service like: @Inject ...