Solved

Delay mouseover event

Posted on 2014-11-16
3
325 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 500 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
JavaScript Loan Calculator Error 3 34
Link Anchor Not working 9 47
Compute age Html 2 25
assigning javascript variable to php variable 8 41
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

749 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