You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
857 B
37 lines
857 B
|
3 years ago
|
import { watch } from "vue-demi";
|
||
|
|
import { toLngLats } from "../../../utils";
|
||
|
|
import { Props } from "./";
|
||
|
|
|
||
|
|
export function useWatch({ props, instance }: { props: Props; instance: T.Polyline }) {
|
||
|
|
watch(
|
||
|
|
() => props.path,
|
||
|
|
val => val && instance.setLngLats(toLngLats(val))
|
||
|
|
);
|
||
|
|
watch(
|
||
|
|
() => props.color,
|
||
|
|
val => val && instance.setColor(val)
|
||
|
|
);
|
||
|
|
watch(
|
||
|
|
() => props.opacity,
|
||
|
|
val => val && instance.setOpacity(val)
|
||
|
|
);
|
||
|
|
watch(
|
||
|
|
() => props.weight,
|
||
|
|
val => val && instance.setWeight(val)
|
||
|
|
);
|
||
|
|
watch(
|
||
|
|
() => props.lineStyle,
|
||
|
|
val => val && instance.setLineStyle(val)
|
||
|
|
);
|
||
|
|
watch(
|
||
|
|
() => props.edit,
|
||
|
|
val => (val ? instance.enableEdit() : instance.disableEdit()),
|
||
|
|
{ immediate: true }
|
||
|
|
);
|
||
|
|
watch(
|
||
|
|
() => props.visible,
|
||
|
|
val => (val ? instance.show() : instance.hide()),
|
||
|
|
{ immediate: true }
|
||
|
|
);
|
||
|
|
}
|