javascript - e.preventDefault on mousemove not working with niceScroll -


this js fiddle depicts problem i'm in.

i'm using nice scroll plugin in site. works fine.

but in 1 page, have show timeline width 1000px. client want scroll down smoothly till timeline.

when mouse pointer in timeline div, scroll should move horizontally.

i've added code site.

document.getelementbyid('tl-scroll').addeventlistener('mousewheel', function(e) {   this.scrollleft -= (e.wheeldelta);   e.preventdefault();     }, false); 

it seems preventdefault not working nicescroll.

please me clear error.

you need use use return false; instead of e.preventdefault();

try updated js code:

$(document).ready(function() {      $("html").nicescroll(); });   // missed close above. syntax error.        document.getelementbyid('tl-scroll').addeventlistener('mousewheel', function(event) {   this.scrollleft -= (event.wheeldelta);   console.log('i have stopped it');   return false; // instead of e.preventdefault(); need use "return false;" }, false); $('#tl-scroll').getnicescroll().hide(); 

the given fiddle has console issues , jquery library loading problems. have fixed it, check out working fiddle.

i suggest use cdn references here fiddle.

hope helps :)


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -