# WHEEL Handler: Get before and after height?

**URL:** <https://community.cesium.com/t/wheel-handler-get-before-and-after-height/1136>\
**Category:** CesiumJS\
**Created:** [April 14, 2014, 4:31pm UTC](https://community.cesium.com/t/wheel-handler-get-before-and-after-height/1136 "2014-04-14T16:31:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_T](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@Adam\_T](https://community.cesium.com/u/Adam_T)\
**Post date:** [April 14, 2014, 4:31pm UTC](https://community.cesium.com/t/wheel-handler-get-before-and-after-height/1136/1 "2014-04-14T16:31:00Z")

</div>

Hi all,

This is probably a simple question, but how can I get the before and after height of a WHEEL ScreenSpaceEventHandler?

Here's what I have:

&nbsp;&nbsp;&nbsp;&nbsp;// Wheel Handler: Functionality for zoom in/out (mouse wheel)  
&nbsp;&nbsp;&nbsp;&nbsp;WheelHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);  
&nbsp;&nbsp;&nbsp;&nbsp;WheelHandler.setInputAction(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function (event) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var mousePosition = scene.camera.position;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var height = ellipsoid.cartesianToCartographic(mousePosition).height;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("Zoom: " + event + " | Height: " + height);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}, Cesium.CameraEventType.WHEEL);

The console generally logs this on zoom in/out:

Zoom: 120 | Height: 1383.0302729777552  
Zoom: 120 | Height: 924.5651569244244  
Zoom: 120 | Height: 620.3080954100334  
Zoom: -120 | Height: 418.39081047853193  
Zoom: -120 | Height: 552.3926363814553  
Zoom: -120 | Height: 731.466938753359

The height is always the starting height, and I'm not sure what the zoom is representing (some factor of how far to zoom I'm guessing?) Since the 'event' parameter is only giving me an integer, are there any other options? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Dan\_Bagnell](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@Dan\_Bagnell](https://community.cesium.com/u/Dan_Bagnell)\
**Post date:** [April 14, 2014, 7:09pm UTC](https://community.cesium.com/t/wheel-handler-get-before-and-after-height/1136/2 "2014-04-14T19:09:10Z")

</div>

The +/- 120 that you are seeing is the amount in degrees the wheel was turned. The amount to zoom is based mostly on that number and the current height of the camera.

You could add a custom render loop. For example, if you are using the Viewer:

viewer.useDefaultRenderLoop = false;

var scene = viewer.scene;

var camera = scene.camera;

function render() {

viewer.resize();

var currentHeight = ellipsoid.cartesianToCartographic(camera.position).height;

scene.initializeFrame();

var currentTime = viewer.clock.tick();

var newHeight = ellipsoid.cartesianToCartographic(camera.position).height;

if (newHeight !== currentHeight) {

// camera zoomed

}

scene.render(currentTime);

Cesium.requestAnimationFrame(render);

}

Cesium.requestAnimationFrame(render);

Regards,

Dan
