NRA Posted June 23, 2018 Share Posted June 23, 2018 Hi, I have this code to evaluate onmousewheel in the screen! How can i use it in Babylon? In fact I want to use the "rolled" var value in a babylon script! <head> <script type="text/javascript"> function MouseScroll (event) { var rolled = 0; if ('wheelDelta' in event) { rolled = event.wheelDelta; } else { // Firefox // The measurement units of the detail and wheelDelta properties are different. rolled = -40 * event.detail; } var info = document.getElementById ("info"); info.innerHTML = rolled; } function Init () { // for mouse scrolling in Firefox var elem = document.getElementById ("myDiv"); if (elem.addEventListener) { // all browsers except IE before version 9 // Internet Explorer, Opera, Google Chrome and Safari elem.addEventListener ("mousewheel", MouseScroll, false); // Firefox elem.addEventListener ("DOMMouseScroll", MouseScroll, false); } else { if (elem.attachEvent) { // IE before version 9 elem.attachEvent ("onmousewheel", MouseScroll); } } } </script> </head> <body onload="Init ();"> Use the mouse wheel on the field below. <div id="myDiv" style="width:200px; height:200px; overflow:auto;"> <div style="height:2000px; background-color:#a08080;"></div> </div> <br /> The last roll amount: <span id="info" style="background-color:#e0e0d0;"></span> </body> Quote Link to comment Share on other sites More sharing options...
Arte Posted June 23, 2018 Share Posted June 23, 2018 Hi @NRA Maybe this will help you? https://www.babylonjs-playground.com/#EU1W1M https://www.babylonjs-playground.com/#08KEYA#30 Quote Link to comment Share on other sites More sharing options...
NRA Posted June 23, 2018 Author Share Posted June 23, 2018 Hi @Arte I use the second approach and it works perfect!!! Thank you!!! Arte 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.