title: jQuery trouble combining 2 functions
body: <p>I am trying to have this working in the following way:</p>
  <p>IF class is <code>.lazy</code> AND IF visible in viewport THEN add class <code>.already-visible</code> otherwise add class <code>.come-in</code>
  BUT IF class is <code>.lazy-up</code> AND IF visible in viewport THEN add class <code>.already-visible-up</code> otherwise add class <code>.come-up</code></p>
  <p>:)</p>
  <p>Here below is my code, but it triggers only the first part... please help 
  Thank you thank you!</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>(function($) {
    $.fn.visible = function(partial) {
      var $t = $(this),
        $w = $(window),
        viewTop = $w.scrollTop(),
        viewBottom = viewTop + $w.height(),
        _top = $t.offset().top,
        _bottom = _top + $t.height(),
        compareTop = partial === true ? _bottom : _top,
        compareBottom = partial === true ? _top : _bottom;
      return ((compareBottom &lt;=
        viewBottom) &amp;&amp; (compareTop &gt;= viewTop));
    };
  })(jQuery);
  var win = $(window);
  var allMods = $(".lazy");
  allMods.each(function(i, el) {
    var el = $(el);
    if (el.visible(true)) {
      el.addClass("already-visible");
    }
  });
  win.scroll(function(event) {
    allMods.each(function(i, el) {
      var el = $(el);
      if (el.visible(true)) {
        el.addClass("come-in");
      }
    });
  });
  (jQuery);
  var win = $(window);
  var allMods = $(".lazy-up");
  allMods.each(function(i, el) {
    var el = $(el);
    if (el.visible(true)) {
      el.addClass("already-visible-up");
    }
  });
  win.scroll(function(event) {
    allMods.each(function(i, el) {
      var el = $(el);
      if (el.visible(true)) {
        el.addClass("come-up");
      }
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>