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
Post a Comment