Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delay mouseover event

Posted on 2014-11-16
3
Medium Priority
?
377 Views
Last Modified: 2014-11-17
I would like to delay this mouseover event so it should only fire if the mouse is hovered over an element for at least 500ms. Is this possible?

	lastMarker = marker;
	google.maps.event.addListener(marker, 'mouseover', function() {
	  if (lastInfoWindow) {
			controlToggle("show");
			lastInfoWindow.close();
		}
		controlToggle("hide");
		
		if(typeof infobox_js!="undefined"){
			infowindow.setContent(this.html);
		}
		google.maps.event.addListener(infowindow, 'closeclick', function() {
			controlToggle("show");
		});
		map.panTo(latlng);
		

Open in new window

0
Comment
Question by:seopti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40446506
Use HoverIntent with jQuery- small bit of code that does what you want.
0
 

Author Comment

by:seopti
ID: 40447776
Thank you, downloaded the Hoverintent script. I see it works this way:
$(element).hoverIntent(whatToDoWhenHover, whatToDoWhenOut);

But I'm completely lost how to put it together with this javascript code?

lastMarker = marker;
	google.maps.event.addListener(marker, 'mouseover', function() {
	  if (lastInfoWindow) {
			controlToggle("show");
			lastInfoWindow.close();
		}

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40447794
Wrap your current hover code in a function e.g.
function maphover(){
       if (lastInfoWindow) {
          // the rest of your hover code.
     }
}

Open in new window


Use this for the hover
$("#map-container-id").hoverIntent({
    over: maphover,
    timeout: 500
})

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question