Skip to content

Instantly share code, notes, and snippets.

@422404
Last active June 14, 2018 20:56
Show Gist options
  • Save 422404/ee92a0f4cf546b9607f12de888baaf14 to your computer and use it in GitHub Desktop.
Save 422404/ee92a0f4cf546b9607f12de888baaf14 to your computer and use it in GitHub Desktop.
Prevent opening the side menu by swiping in ExtJS Modern Toolkit

While digging on how to prevent the user to open the side menu by swiping I found nothing. I tried to override the onEdgeSwipe and onSwipeStart methods of Ext.Viewport but nope...

Some tests after, tadaaa ! If I replace the Ext.Viewport.beforeMenuAnimate method with an empty function it prevent the menu opening by swiping... and by calling Ext.Viewport.showMenu(..)

The solution

let oldBeforeMenuAnimate = null;
let noop = function () {};

let viewportPreventEdgeSwipe = function () {
    oldBeforeMenuAnimate = Ext.Viewport.beforeMenuAnimate;
    Ext.Viewport.beforeMenuAnimate = noop;
}

let openMenu = function () {
    Ext.Viewport.beforeMenuAnimate = oldBeforeMenuAnimate;
    Ext.Viewport.showMenu('right');
    Ext.Viewport.beforeMenuAnimate = noop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment