Advertisements
RSS

Using the wheel mouse button with AjaxControlToolkit slider

10 Jun

 I wanted to use the wheel mouse button to slide the slider up or down to use it in a Mapping application for Zoom In/Out, I used a java script function to detect the wheel mouse on the Map, I wanted the Zoom function to start when the user release the wheel mouse so I added a timer to detect that the user stopped using the wheel button 

 

   var hTimer = null;

 

   function wheelZoom(e)

    {

        try

        {

            e = e ? e : window.event;

            var raw = e.detail ? e.detail : e.wheelDelta;

            var normal = e.detail ? e.detail * -1 : e.wheelDelta / 40;

            if (normal > 0)

            {

                var slider = $find(“Slider2”);

                if (slider != null)

                {

                    slider.set_Value(slider.get_Value()-1);

                }

                else

                {

                }

            }

            else if(normal < 0)

            {

                var slider = $find(“Slider2”);

                if (slider != null)

                {

                    slider.set_Value(slider.get_Value()+1);

                }

                else

                {

                }

            }

            if (hTimer != null)

            {

                window.clearTimeout(hTimer)

            }

            else   

            {

           

            }

            hTimer = window.setTimeout(doZoomWheel, 500)

            cancelEvent(e);

        }

        catch(err)

          {

            alert(err.message)

          }

          finally

          {

                  

          }

    }

 

In the above code the slider will response to the wheel mouse but the Zoom function will be called only when the user stop using the wheel button

 

 

function doZoomWheel()

    {

        if (hTimer)

        {

            hTimer = null;

            Zoom();

        }

    }

 

 

 

Advertisements
 
Leave a comment

Posted by on June 10, 2008 in General, Photography

 

Tags: , , , , , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: