ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
680 stars 227 forks source link

change:active events on interaction components doesnt emit #362

Closed aliciahogue closed 3 years ago

aliciahogue commented 3 years ago

the @change events dont seem to be coming through on this --

<vl-interaction-modify :active="editing" @change:active="applyUpdates" :wrap-x="true" source="draw-target"

ghettovoice commented 3 years ago

Hello @aliciahogue , in v0.11.x is not synchronizable property. And actually there is no need for this, because this property not changed inside interaction components. Interactions just reacts on active property change.

You pass editing field to the active property, so what you need is a watcher for editing field.

<template>
  <vl-interaction-modify :active="editing" ... />
</template>

<script>
export default {
  ...
  data () {
    return {
      editing: false,
    }
  },
  watch: {
    editing (val) {
      // do what you want
    },
  },
}
</script>
aliciahogue commented 3 years ago

Sorry this was on v12. I did end up adding the watcher for editing after I noticed the change functions were not firing.

ghettovoice commented 3 years ago

Ok. In v0.12 active property is synchronizable, but the event name is update:active so it is covered by Vue .sync modifier. And still this event will be fired only if input active property will differ from actual interaction state, i.e. changed internally or directly on interaction instance https://github.com/ghettovoice/vuelayers/blob/master/src/mixins/interaction.js#L79.

So anyway you need a watcher for editing field. The difference between v0.11 and v0.12 that in v0.12 your watcher will be triggered also for out of Vue scope changes.

aliciahogue commented 3 years ago

ty!!