Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 68507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:25:38+00:00 2026-05-10T19:25:38+00:00

So I have a control (a map) on an aspx page. I want to

  • 0

So I have a control (a map) on an aspx page. I want to write some javascript to onload setup the following:

  1. when mouse stops on control = some code

  2. when mouse moves = some code (but only if the move is longer than 250 mil sec)

This works to trigger code on stop and then on move…

function setupmousemovement() { var map1 = document.getElementById('Map_Panel'); var map = document.getElementById('Map1'); map1.onmousemove = (function() {     var onmousestop = function() {             //code to do on stop     }, thread;      return function() {         //code to do on mouse move         clearTimeout(thread);         thread = setTimeout(onmousestop, 25);     };     })(); }; 

But I cannot figure out how to introduce a delay into the on move code. I thought I had it with this…

function setupmousemovement() { var map1 = document.getElementById('Map_Panel'); var map = document.getElementById('Map1'); map1.onmousemove = (function() {     var onmousestop = function() {             //code to do on stop             clearTimeout(thread2);     }, thread;      return function() {         thread2 = setTimeout('code to do on mouse move', 250);         clearTimeout(thread);         thread = setTimeout(onmousestop, 25);     };     })(); }; 

But it does not behave as I thought it would. The on move ‘thread2’ is never cleared by the stop. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:25:39+00:00Added an answer on May 10, 2026 at 7:25 pm

    That is a tricky one. A little bit of tinkering resulted in this:

    function setupmousemovement() {    var map1 = document.getElementById('Map_Panel');   map1.onmousemove = (function() {     var timer,         timer250,         onmousestop = function() {            // code to do on stop            clearTimeout( timer250 ); // I'm assuming we don't want this to happen if mouse stopped           timer = null;  // this needs to be falsy next mousemove start         };     return function() {       if (!timer) {          // code to do on start          timer250 = setTimeout(function () { // you can replace this with whatever            // code to do when 250 millis have passed          }, 250 );       }       // we are still moving, or this is our first time here...       clearTimeout( timer );  // remove active end timer       timer = setTimeout( onmousestop, 25 );  // delay the stopping action another 25 millis     };    })();  }; 

    The reason your code does not work is that mousemove fires repeatedly while the mouse is moving and you are starting new timeouts every time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some code that I don't have control over is overriding the global JSON object
I have an .aspx page that contains a ReportViewer control. The report displays properly,
I have map control on main form. Problem is, when form designer generate code
I have some map control and when I clicked on it, I open contextMenuStrip
I have page which is desgined for map point browsing. I want to show
I have control, subclassed from CDialogBar, it has some buttons(like on toolbar). When I
I want to read UTF-8 strings from a server that I have control of,
I have a Silverlight application with some maps, and in the same page this
In in aspx page, there is a grid view, that has template control for
Well basically, I have this bing map control inside my Panorama view, when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.