title: How to close a side bar in mobile view when user perform "scroll" or "touch" or "Click" Event
body: <p>I am trying to developing a website, which contains a sidebar, navbar and body panel. It is a responsive website. In the mobile view when the user clicks on the hamburger icon a sidebar will open, So I wanted to close it after when the user performs any "Touch" event on the element other than sidebar i.e on the body panel.</p>
  
  <p>Sidebar code:</p>
  
  <pre><code>&lt;div id="sidebar-nav" class="sidebar"&gt;
      &lt;div class="sidebar-scroll"&gt;
          &lt;nav&gt;
              &lt;ul class="nav"&gt;
                  &lt;li&gt; Sidebar element &lt;/li&gt;                
              &lt;/ul&gt;
          &lt;/nav&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Navbar code:</p>
  
  <pre><code>&lt;nav class="navbar navbar-default navbar-fixed-top"&gt;
      &lt;div class="brand"&gt;
      &lt;/div&gt;
      &lt;div class="container-fluid"&gt;
          &lt;div class="navbar-btn"&gt;
              &lt;button type="button" class="btn-toggle-fullwidth"&gt;&lt;i class="fa fa-bars"&gt;&lt;/i&gt;&lt;/button&gt;
          &lt;/div&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>Body panel code:</p>
  
  <pre><code>&lt;html lang="en"&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="wrapper"&gt;
              &lt;div class="main"&gt;
                  &lt;div class = "article_view"&gt; 
                      &lt;!-- this is the body panel --&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Please note that I did for the click event. It is working properly. </p>
  
  <pre><code>$(".article_view").click(function(e) {
      if ($("body").hasClass("layout-fullwidth offcanvas-active")) {
           $("body").removeClass("layout-fullwidth offcanvas-active");
             $("body").toggleClass("undefined")
      }
  })
  </code></pre>
  
  <p>For example:</p>
  
  <p>Open <code>youtube.com</code> in mobile view and open sidebar and perform events on body such as touch, or swipe. Automatically sidebar will close. (I wanted to do like this)</p>
  
  <p>Open <code>stackoverflow.com's</code> sidebar and perform the same events as swipe or touch. The sidebar will not close. </p>
  
  <p>Please let me know how to handle touch events in the mobile view (swipe left, swipe down, swipe right or touch).</p>