JavaScript - iScroll - mousedown not triggering

344 views Asked by At

We are using iScroll in our project, and some elements in it's scroll area have mousedown event attached.

On newest build of Google Chrome(55.0.2883.95 (64-bit)) mousedown event is never triggered and the reason is pointerdown event registered by IScroll.

Is there any way around it? I could of course use pointerdown instead of mousedown, but it is not supported in Safari, therefore I would need some dirty browser check.

(function () {
  var scroll = new IScroll('#scroller');

  document.getElementById('testblock').addEventListener('mousedown', mousedownEventHandler);
  
  function mousedownEventHandler(event) {
    console.info(event.type, 'triggered.');
  }
})();
body {
  padding: 0;
  margin: 0;
}

#scroller {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
}

#content {
  height: 5000px;
  background: white;
}

#testblock {
  position: fixed;
  top: 0;
  width: 100px;
  height: 100px;
  line-height: 100px;
  background: silver;
  border: 1px solid black;
  cursor: pointer;
  text-align: center;
}
<script src="https://rawgit.com/cubiq/iscroll/master/build/iscroll-probe.js"></script>
<div id="scroller">
  <div id="content">
    <div id="testblock">Click me</div>
  </div>
</div>

1

There are 1 answers

4
chrismauck On BEST ANSWER

You need to add the click parameter to the options object.

var scroll = new IScroll('#scroller', {
    click: true
});