Commit 24933e26 authored by Michael Underwood's avatar Michael Underwood
Browse files

Add props to disable control event propagation

parent e1f44a76
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -5,7 +5,19 @@ import { propsBinder } from "../utils.js";

export default {
  name: "LControl",
  props,
  props: {
    ...props,
    disableClickPropagation: {
      type: Boolean,
      custom: true,
      default: true,
    },
    disableScrollPropagation: {
      type: Boolean,
      custom: true,
      default: false,
    },
  },
  setup(props, context) {
    const leafletRef = ref({});
    const root = ref(null);
@@ -13,7 +25,7 @@ export default {
    const registerControl = inject("registerControl");
    const { options, methods } = controlSetup(props, leafletRef);
    onMounted(async () => {
      const { Control, setOptions } = await import(
      const { Control, setOptions, DomEvent } = await import(
        "leaflet/dist/leaflet-src.esm"
      );

@@ -22,9 +34,17 @@ export default {
          return root.value;
        },
      });

      leafletRef.value = new LControl(options);
      propsBinder(methods, leafletRef.value, props, setOptions);
      registerControl({ leafletObject: leafletRef.value });

      if (props.disableClickPropagation) {
        DomEvent.disableClickPropagation(root.value);
      }
      if (props.disableScrollPropagation) {
        DomEvent.disableScrollPropagation(root.value);
      }
    });

    return render(context, root);