cheich / jquery.offcanvas

The easy way to arrange overloaded websites or to design user-friendly mobile navigations
11 stars 11 forks source link

How to make a closing a sliding div when you click outside of it? #1

Closed zuber143 closed 7 years ago

zuber143 commented 7 years ago

How to make a closing a sliding div when you click outside of it?

cheich commented 7 years ago

You just have to call .offcanvas('hide') if you click outside the div. Select everything and exclude the canvas.

Untested example:

var canvas = $('#your-selector');
$('html').not(canvas).click(function() {
    canvas.offcanvas('hide');
});