Event javascript to scroll over an area or div

Asked

Viewed 339 times

0

I have a page where an area or div that does not have the Side Scrollbar, simply because it is not necessary.I would like to capture the event when the mouse rotates the roulette over that area because I wanted to use the mouse roulette for Zoom, for example.

2 answers

1


Long live,

Use the ".on" to catch the event. Actually there are two events, to work in the different browsers.. "Dommousescroll mousewheel"

$('#div').on('DOMMouseScroll mousewheel', function ( event ) {
  if( event.originalEvent.detail > 0 || event.originalEvent.wheelDelta < 0 ) {
    console.log('Para baixo');
  } else {
    console.log('Para cima');
  }
  return false;
});
  • worked really well

1

Friend. Has a command to just pass the mouse to zoom in image. As you did not put code.

Follows:

<script language="javascript">
 <!--
  function aumenta(obj){
obj.height=obj.height*2;
obj.width=obj.width*2;
   }

  function diminui(obj){
obj.height=obj.height/2;
obj.width=obj.width/2;
  }
    </script>

Html:

    <p><img src="IMAGEM" width='258' height='45' alt="img" onMouseOver="aumenta(this)" onMouseOut="diminui(this)">
  • Thanks a lot too, but I’m using a third-party plugin to perform the differentiated zoom, just needed the same event. But it also helped!

  • Congratulations to Fabio for the answer. Very good. I didn’t know. I’ll save here too. Kkk

Browser other questions tagged

You are not signed in. Login or sign up in order to post.