Solved

Delay mouseover event

Posted on 2014-11-16
3
259 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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 …
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…

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now