title: Preventing 'Unable to preventDefault inside passive event listener' error within Chrome & OpenLayers 2
body: <p>I use OpenLayers2 (v2.12) to load and generate a map in the user's browser. Recently, Chrome has released an update so that now when I use my mousewheel to zoom in and out of the OpenLayers map, it also causes the whole page to scroll up and down.</p>
  
  <p>Originally, before this Chrome change, if I used my mousewheel within the map it would zoom in and out as intended, but it would not scroll the whole page. It would only start scrolling the page if I used my mousewheel outside of the OpenLayers map (as intended).</p>
  
  <p>When I now use my mousewheel within the map, the following error is shown:</p>
  
  <pre><code>OpenLayers.min.js:2 [Intervention] Unable to preventDefault inside passive 
  event listener due to target being treated as passive. See 
  https://www.chromestatus.com/features/6662647093133312
  </code></pre>
  
  <p>I assume this is the error that is causing the page to scroll. </p>
  
  <p>Looking at similar questions to this error, I have tried to attach a </p>
  
  <pre><code>touch-action: none;
  </code></pre>
  
  <p>CSS style to the OL map container, however this doesn't seem to work.</p>
  
  <p>The error itself points to some code within the actual OpenLayers.js file and not my code and thus I am not completely sure how I go about fixing this error.</p>
  
  <p>The code causing the error within the Openlayers.min.js file is:</p>
  
  <pre><code>OpenLayers.Event = {
      stop: function(e, t) {
          t || (e.preventDefault ? e.preventDefault() : e.returnValue = !1),
          e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0
      },
  }
  </code></pre>
  
  <p>notably the e.preventDefault() function.</p>
  
  <p>The unminified OpenLayers file that I am referencing is:
  <a href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js" rel="noreferrer">https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js</a></p>
  
  <p>The HTML code for the OL map is:</p>
  
  <pre><code>&lt;div class="container-fluid col-xs-12" style="height: 100%;"&gt;
      &lt;div class="row" style="height: 100%;"&gt;
          &lt;div class="custom-col-md-10 col-sm-9 col-xs-8" style="height: 100%; overflow-y: hidden; max-height:850px;max-width:1600px;"&gt;
              &lt;div class="panel" style="height: 100%; border: solid thin; border-color: darkblue;"&gt;
                  &lt;div class="panel-body" style="height: 100%; padding: 0px;"&gt;
                      &lt;div tabindex="0" id="map" style="height: 100%; width: 100%;"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
         &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am looking for a solution, so that when I use my mousewheel within the OpenLayers map it only zooms in and out of the map, doesn't start scrolling the page too, and the 'unable to preventDefault' error no longer appears.</p>
  
  <p>This only seems to be a Chrome problem. It works as intended in Firefox and Edge.</p>
  
  <p>Many thanks for any help.</p>