Solved

Delay mouseover event

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

708 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

16 Experts available now in Live!

Get 1:1 Help Now