Skip to content

Instantly share code, notes, and snippets.

@collinprice
Created May 28, 2015 20:50
Show Gist options
  • Save collinprice/9d14803c37b8e26a5919 to your computer and use it in GitHub Desktop.
Save collinprice/9d14803c37b8e26a5919 to your computer and use it in GitHub Desktop.
NappDrawer back button capture. This sample closes the sidebar.

You could accomplish this yourself. Add an event listener to watch for the android back button pressed. Here is a code sample that should accomplish this. There are two event listeners because Android emits different events depending on the version. See docs.

$.drawer.window.addEventListener('android:back', androidBackPressed);
$.drawer.window.addEventListener('androidback', androidBackPressed);

function androidBackPressed() {
  if ($.drawer.isLeftWindowOpen) {
    $.drawer.toggleLeftWindow();
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment