Reputation: 4262
I want to create an click and a touch start event here is my code:
google.maps.event.addDomListener(div, "click",function(event: any) {
google.maps.event.trigger(self.overlayView, "click");
event.stopPropagation();
});
How do I create an simple implementation for this without doing this:
google.maps.event.addDomListener(div, "touchstart",function(event: any) {
google.maps.event.trigger(self.overlayView, "click");
event.stopPropagation();
});
Upvotes: 0
Views: 23
Reputation: 24915
You can export function to a named function and bind same function to both event.
document.getElementsByClassName('tile')[0].addEventListener('click', handler)
document.getElementsByClassName('tile')[0].addEventListener('mousedown', handler)
function handler(e) {
console.log(e)
}
Upvotes: 1