Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta.11] menu oberlay does not disable page scrolling #15725

Closed
Yomyer opened this issue Sep 23, 2018 · 2 comments
Closed

[beta.11] menu oberlay does not disable page scrolling #15725

Yomyer opened this issue Sep 23, 2018 · 2 comments
Assignees

Comments

@Yomyer
Copy link
Contributor

Yomyer commented Sep 23, 2018

Bug Report

Ionic Info
Run ionic info from a terminal/cmd prompt and paste the output below.

Ionic:

   ionic (Ionic CLI)          : 4.1.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.11
   @angular-devkit/core       : 0.8.2
   @angular-devkit/schematics : 0.8.2
   @angular/cli               : 6.1.2
   @ionic/ng-toolkit          : 1.0.8
   @ionic/schematics-angular  : 1.0.6

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.1.0, browser 5.0.4, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview 1.1.1, (and 13 other plugins)

System:

   ios-deploy : 1.9.2
   ios-sim    : 6.1.2
   NodeJS     : v10.10.0 (/usr/local/Cellar/node/10.10.0/bin/node)
   npm        : 6.4.1
   OS         : macOS High Sierra
   Xcode      : Xcode 9.4.1 Build version 9F2000

Describe the Bug
I'm using the menutype overlay and I'm noticing that if there's a content in the page with scroll it doesn't deactivate but allows scrolling.

Thanks.

@ionitron-bot ionitron-bot bot added the triage label Sep 23, 2018
@Yomyer
Copy link
Contributor Author

Yomyer commented Sep 24, 2018

I found a fairly clean solution. It is to create a directive that adds an ionOpen and ionClose listener to the menu component. This looks for ion-content that doesn't have a parent ion-menu and disables and enables scrollY depending on the event.

It works fine but only if you use the toggle button menu. Using the horizontal swipe you can move the scroll :'(

`import { MenuController } from '@ionic/angular';
import { Directive, Renderer2, ElementRef, OnInit, OnDestroy } from '@angular/core';

@directive({
selector: '[menuFix]'
})
export class MenuFixDirective implements OnInit, OnDestroy {
private listener:

get menu(): HTMLIonMenuElement {
    return this.el.nativeElement;
}
constructor(
    private el: ElementRef,
    private renderer: Renderer2,
    private menuCtrl: MenuController
) {
}

ngOnInit(): void {
    this.listener = this.renderer.listen(this.menu, 'ionOpen', (evt) => {
        this.disabled(false);

    });
    this.listener = this.renderer.listen(this.menu, 'ionClose', (evt) => {
        this.disabled(true);
    });
}

disabled(disabled: boolean) {
    const main = document.querySelector('[main]');
    const contents = Array.from(main.querySelectorAll('ion-content'));
    contents.forEach((content: HTMLIonContentElement) => {
        if (!content.closest('ion-menu')) {
            content.scrollY = disabled;
        }
    });
}

ngOnDestroy(): void {
    this.listener();
}

}`

Further research :)

PD: I've seen what happens with dialogs/modal, too.

@manucorporat manucorporat self-assigned this Sep 25, 2018
@ionitron-bot ionitron-bot bot removed the triage label Sep 25, 2018
@ionitron-bot
Copy link

ionitron-bot bot commented Oct 25, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants