jquery - Disable scrolling but capture scrolling data with JavaScript? -
i'm trying prevent default scrolling behavior while still determining number of pixels user has attempted scroll.
my objective (at vertical position on page) fix navigation element top of screen , hijack scroll/swipe event pull down mobile menu when user scrolls (so moving said element , down n pixels depending on how many pixels user tries scroll).
i aware of ux/accessibility concerns insofar blocking native behavior, suits want suits want.
so far have:
$('body').on({ 'mousewheel' : function(e) { e.preventdefault(); e.stoppropagation(); } });
but stumped how access number of pixels scrolled (since element/scroll offsets no longer guide).
edit: please note question asking information regarding mouse/scroll actions while scrolling blocked. don't think has been appropriately marked duplicate.
this browser-depended because of mousewheel
event using. because non-standard. don't use it!
in chrome (43.0) different properties different values:
e.originalevent.wheeldelta: -120 e.originalevent.wheeldeltay: -120 e.originalevent.deltay: 100
in ie (11.0), can 1 property:
e.originalevent.wheeldelta: -120
in firefox (38.0.5), capturing of mousewheel event doesn't work @ all.
solution:
use wheel
event (mdn reference). event has e.originalevent.deltay
property in browsers.
Comments
Post a Comment