title: Why is the scroll event not working in my div?
body: <p>I have an <code>html</code> with <code>body</code>'s <code>height</code> and <code>width</code> properties set to <code>100%</code>, and a large <code>viewport</code> <code>div</code> for scrolling.</p>
  
  <p>I want to catch the event in both desktop and mobile browsers.</p>
  
  <p>But now, it's not working, when the <code>viewport</code> <code>div</code> is scrolling.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>;
  (function() {
    var viewport = document.getElementById('viewport');
  
    function test() {
      console.log("aaa");
    }
  
    viewport.addEventListener('scroll', test, false);
    //nothing happen here
  
    window.addEventListener('resize', function() {
  
    }, false);
  
  })();</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#box {
    width: 100px;
    height: 100px;
    background: red;
    position: absolute;
  }
  
  #viewport {
    width: 12222px;
    height: 5000px;
    position: relative;
    top: 0;
    left: 0;
    background-color: gray;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255, 255, 255, .5) 35px, rgba(255, 255, 255, .5) 70px);
  }
  
  html,
  body {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: scroll;
  }
  
  #info {
    position: fixed;
    top: 30%;
    font-size: 2em;
    z-index: 1;
    width: 100%;
    text-align: center;
    color: #fff;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"&gt;
  
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
    &lt;p id="info"&gt;text&lt;/p&gt;
    &lt;div id="viewport"&gt;
      &lt;div id="box"&gt;&lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>How can I get this to work?</p>