title: NiceScroll show/hide
body: <p>I'd like to hide/show <code>NiceScroll</code> based on the result of an <code>if</code> function.</p>
  
  <p>In my <code>html</code> there are three sections which are scrolled from left to right one by one. </p>
  
  <p>My script is as follows:</p>
  
  <pre><code>var section2 = $('#section2').offset().left; 
  $(window).scroll(function(){
      var scrollZpos = $(document).scrollLeft();
      if (scrollZpos &lt;= section2 ) {
          $("body").getNiceScroll().hide();
      }
      if (scrollZpos == section2 ) {
          $("body").niceScroll({touchbehavior:false,cursorcolor:"#67a5df",horizrailenabled:false,cursoropacitymax:1,autohidemode:false,cursorwidth:10,cursorborder:0,cursorborderradius:0,cursorminheight:180});
      }
      else if(scrollZpos &gt;= section2 ){
          $("body").getNiceScroll().hide();
      }
  });
  </code></pre>
  
  <p>It hides when scrolling outside of section 2, but when scrolling back it doesn't reappear.</p>