allow map to define custom map events
Add handlers and listeners for events explicitly passed as a prop. This addresses fawmi/vue-google-maps#47
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
export default (vueInst, googleMapsInst, events) => {
|
||||
for (let eventName of events) {
|
||||
if (vueInst.$gmapOptions.autobindAllEvents || vueInst.$attrs[eventName]) {
|
||||
const propName = `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`.replace(/[-_]+(.)?/g, (_, c) => c ? c.toUpperCase() : '');
|
||||
|
||||
if (vueInst.$props[propName] || vueInst.$attrs[propName]) {
|
||||
googleMapsInst.addListener(eventName, (ev) => {
|
||||
vueInst.$emit(eventName, ev)
|
||||
})
|
||||
} else if (vueInst.$gmapOptions.autobindAllEvents || vueInst.$attrs[eventName]) {
|
||||
googleMapsInst.addListener(eventName, (ev) => {
|
||||
vueInst.$emit(eventName, ev)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user