javascript - Calling functions when the mouse wheel moves -


I'm beginning to use JavaScript and jquery and do not know me yet complete I make some code I am trying to call different functions if the mouse wheel moves in some directions that is compatible with most or all programs. Can anyone show me an example of code using the piece, how is this implemented?

In this way I will need to set it up

  // javascript document .... .... ... function wheelMove () {// Note: I do not want to like the scrolling event // Do not fire (or something is wrong, or something like this) // If the variable is to be set, they can go to // ... //. .. // if (// to know, some code wheel is moving in the right direction) {var sRight = // something in this direction to detect the speed; MoveRight (sRight); // calls a function when it runs correctly; } If (// can find some code that the wheel is moving to the left) {var sLeft = // some code to detect motion in this direction; MoveLeft (sLeft); // calls a function when it is skipped; } If (// there is a wheel in this direction, some code to know) {var sUp = // some code to detect motion in this direction; moveUp (SUP); // When it goes up, a function calls; } If (// something is moving downward, some code to know) {var sDown = // some code to detect motion in this direction; MoveDown (sDown); // calls a function when it moves down; }}    

Here is an example (and here):

  $ ( '#scrollCatcher') .on ( 'mousewheel', function (event) are supported {// events if (typeof see event.originalEvent.wheelDeltaX === 'undefined' check crude | | typeof event.originalEvent.wheelDeltaY === 'undefined') {console.log ( "mouse Delta could not find"); return;} var deltaX = event.originalEvent.wheelDeltaX; var DeltaY = event.originalEvent.wheelDeltaY; var scrolledLeft = deltaX & LT; 0; var scrolledRight = deltaX & gt; 0; var scrolledUp = deltaY & LT; 0; var scrolledDown = deltaY & gt; 0; clearDisplay (); if (scrolledLeft) Shine Shn (scroll left '');} if (ScrolledRight) {} (ScrolledUp);} if (scrolledUp) {Display ( 'scrolled up');} if (scrolledownown) {Display ( "scroll") below;}} ); Clear the Function () {$ ('#scrollCatcher') .text (''); } Function Display (Message) {$ ('#ccrollCatcher') .text ($ ('#scrollCatcher') .text () + Message + ''); }   

To interpret deltaX and deltaY are traveling from the scroll wheel since the last event. Where display is, for example you can change it with your code:

  if (scrolledLeft) {moveLeft (deltaX)}    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -