Solved

Delay mouseover event

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…

739 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