lgraubner / jquery-offcanvas

An easy to use jQuery offcanvas plugin.
http://lgraubner.github.io/jquery-offcanvas
MIT License
21 stars 6 forks source link

Click offcanvas-outer to hide. #4

Open ivorpad opened 7 years ago

ivorpad commented 7 years ago

Can't get my head around this:

$($el).on('shown.offcanvas', function() {
    $('.offcanvas-outer').on('click', function() {
      $el.offcanvas('hide');
    });
});

Once hidden the trigger doesn't work correctly.

lgraubner commented 7 years ago

You can achieve this by setting overlay: true and overlayColor: transparent. The overlay spans over the whole content and closes the offcanvas part on click. The transparent makes it invisible.

ivorpad commented 7 years ago

Yeah I tried that, unfortunately overlay: true is giving me performance issues.

I'm using esc in the meantime.

$($el).on("shown.offcanvas", function() {
    $(document).keyup(function(e) {
      if( e.keyCode === 27 ) {
        $el.offcanvas("hide");
      }
    });
});

By the way, thanks for the plugin.