ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

feat: Disable vertical scroll when menu is being dragged

Open andrefedalto opened this issue 10 years ago • 4 comments

Type: feat

Ionic Version: 2.x

Platform: mobile webview

I noticed this while dragging the sidemenu diagonally: the menu would open/close and scroll at the same time and for some reason the transition becomes a bit lagged while doing this.

The gmail app, for example, completely disable the vertical scrolling of the menu while it is being dragged to open/close. Maybe Ionic should have the same behaviour?

andrefedalto avatar Jan 25 '16 10:01 andrefedalto

I opened an identical issue almost at the same time #5181. I will close the one I opened.

Additionally to disabling the menu while it is being dragged it is also to note that it is only possible to scroll vertically without dragging the menu with a perfect vertical movement.

dkro avatar Jan 25 '16 12:01 dkro

I created a PR for restraining the menu to open and close only at a specific angle.

As for preventing horizontal scroll while opening and closing my solution was to listen to the opening event of the menu and adjust the class of the content accordingly. Maybe this behavior can be integrated directly into ionic as well.

<ion-menu [content]="content" (opening)=preventYScroll() id="leftMenu">
    <ion-toolbar>
        <ion-title>Menu</ion-title>
    </ion-toolbar>

    <ion-content id="menu-content" overflow-scroll='true'>
        <ion-list>
            ...
        </ion-list>
    </ion-content>
</ion-menu>
    ngAfterViewInit() {
        this.content = this.app.getComponent('menu-content');
    }
    preventYScroll() {
        this.content.scrollElement.style['overflow-y'] = 'hidden';
        if(this.timer !== null) {
            clearTimeout(this.timer);
        }
        this.timer = setTimeout(() => {
            this.content.scrollElement.style['overflow-y'] = 'scroll';
        }, 300);
    }

dkro avatar Jan 25 '16 13:01 dkro

Good trick there, hopefully the pros can integrate this behaviour into v2 :)

andrefedalto avatar Jan 26 '16 13:01 andrefedalto

Closing this as the PR was merged. Please let us know if it is still an issue, thanks!

brandyscarney avatar Feb 03 '16 22:02 brandyscarney