question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat(sidenav): add swipe functionality

See original GitHub issue

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

It’d be great to have the functionality of swipe in md-sidenav, like in https://material.io/guidelines/.

What are the steps to reproduce?

Open https://material.io/guidelines/ in mobile and see how the swipe on menu works.

Is there anything else we should know?

The same feature request was requested in material(1) here and at some point it was implemented, but not merged.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:56
  • Comments:39 (6 by maintainers)

github_iconTop GitHub Comments

48reactions
maxfriedmanncommented, May 29, 2018

@Swoox’s solution didn’t work for me, but brought me to hammerjs and this solution:

app-container.component.scss

.app-container {
    height: 100%;
    width: 100%;
    position: absolute;
}

app-container.component.html

<mat-sidenav-container class="app-container">
  <mat-sidenav #sidenav>Sidenav content</mat-sidenav>
  <mat-sidenav-content>
    Main Content
  </mat-sidenav-content>
</mat-sidenav-container>

app-container.component.ts

import { Component, Input, ElementRef, ViewChild } from '@angular/core';
import * as Hammer from 'hammerjs';
import { MatSidenav } from '@angular/material';

@Component({
    selector: 'app-container',
    templateUrl: './app-container.component.html',
    styleUrls: ['./app-container.component.scss']
})
export class AppContainerComponent {

    @ViewChild(MatSidenav)
    public sidenav: MatSidenav;

    constructor(elementRef: ElementRef) {
        const hammertime = new Hammer(elementRef.nativeElement, {});
        hammertime.on('panright', (ev) => {
            this.sidenav.open();
        });
        hammertime.on('panleft', (ev) => {
            this.sidenav.close();
        });
    }
}

It works as long as the content doesn’t exceed the width of 100%, otherwise it will scroll the page and open the menu.

29reactions
jelbourncommented, Jul 13, 2017

We do plan on doing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - feat(sidenav): add swipe functionality - - Bountysource
Add the same swipe functionality behavior as ion-side-menus to open sidenav not just with click but with swipe left (or right). Awesome work!...
Read more >
How add custom swipe navigation for mostslider jQuery plugin?
I am using the mostslider.js jquery Plugin. I need to add swipe navigation for the slider in mobile view, sadly mostslider doesn't support...
Read more >
Angular Material: Sidebar Open on Swipe - DEV Community ‍ ‍
In part 3, we are going to add swipe to left open sidebar feature. In order to accomplish this task there are three...
Read more >
Blogging - Marketing & Copywriting Examples - Swipe-Worthy
View Swipe. “Content Recommendation” Ad Tactics (Image-Based) ... Swipe Study. Sidebar Opt-In Form from Quick Sprout ... Feature Box from Social Triggers.
Read more >
Obscure Mobile Design Techniques That Boost UX
In addition to all of the swiping functionality that we've become ... However, V for Wiki has made it even more accessible by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found