ionic-framework: bug: ASSERT: can not be animating in menuController.swipeGesture(false, 'main')

Bug Report

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

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.7.1
   @angular-devkit/build-angular : 0.802.0
   @angular-devkit/schematics    : 8.2.0
   @angular/cli                  : 8.2.0
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : browser 5.0.4, ios 5.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 23 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/yerko/Library/Android/sdk)
   ios-deploy        : 1.9.4
   ios-sim           : 7.0.0
   NodeJS            : v10.15.2 (/usr/local/Cellar/node@10/10.15.2_1/bin/node)
   npm               : 6.4.1
   OS                : macOS High Sierra
   Xcode             : Xcode 10.1 Build version 10B61

Describe the Bug

It only happens when I try to off the swipeGesture. I have tried it in several ways:

await this.menuCtrl.swipeGesture(false, 'main');

document.querySelector('ion-menu-controller').swipeGesture(false, 'main')

this.menuCtrl.get('main').then((menu: HTMLIonMenuElement) => {
   menu.swipeGesture = true;
});

But all with the same result.

ASSERT: can not be animating

This is the part of the code I use, in previous versions it worked perfectly. Basically what it does is that when the modal opens, it closes the menu (if it is open) and doesn’t let it swipe so that it doesn’t reopen unintentionally when the user is navigating through the modal.

       this.current = await this.modalCtrl.create(options);

       await this.menuCtrl.swipeGesture(false, 'main');

       this.current.present();

       this.current.onWillDismiss().then(async response => {
            await this.menuCtrl.swipeGesture(true, 'main');
       });

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 32 (4 by maintainers)

Commits related to this issue

Most upvoted comments

And clearly should not have a debugger; thrown in there either.

It might be the case that the error ASSERT: can not be animating is not triggering due to a bug, although i cannot say that with certainty.

The following behavior triggered the same error in my case:

  1. Toggle the side menu open
  2. Tap a link which exists inside an ion-menu-toggle in the side menu which automatically triggers the menu to close in addition to triggering a click event i set on the link which calls a logout() method in my app component.
  3. After logging out the user, the very next task in my logout() method was to disable the swipe gesture, and with that i got the ASSERT: can not be animating error

I suspected that i might have been disabling the swipe gesture too early since both the animation of the menu closing and my logout() method are running asynchronously.

To test this theory, i wrapped the line that disables the swipe gesture in a setTimeout() of 1 second and i no longer get the error.

So i am assuming the menu cannot be animating, just as the error implies, when attempting to set the gesture control to false

Can anyone from the ionic team respond?

What i am doing to avoid the error is to avoid using an ion-menu-toggle component. It is more work, but i am using the menuController.close() method to close the menu programmatically inside of my logout() method, and in the menuController’s .then() callback i finally set the swipe gesture to false. This ensures that the menu has finished closing at which point it is safe to set the swipe gesture to false.

bump - same issue

raise again on ionic 7

Bumping because this still hasn’t been fixed. Currently trying to set subcomponents of a menu to true or false in Ionic React and this debugger is thrown - very frustrating

Guys, I told you : an error is normal in that case because the user click on the menu while the opening/closing animation is running.

So the simple solution is disable the menu during animation or wait for the end of the swap animation.

What ionic should fix is the “assert” -> it should be a normal error with a logger. And, since it is javascript, it should be invisible to the end user and nothing should happen (especially not a crash).

Secondly, the current error message is very unclear. It should be improved.

Was this fixed or just closed for no reason?

Same error(can not be animating) is here with 5.2.3 as well… When using ion-split-pane on the bigger screen, it happens.

I think Ionic core team better focuses on Angular more…