bugfix: controls not having correct zoom helper functions

* Check if prop event cbs are functions before calling
This commit is contained in:
Braks
2021-07-09 18:11:47 +02:00
parent 4319e2ac49
commit 3a8dde7cbd
2 changed files with 16 additions and 12 deletions
+9 -5
View File
@@ -31,7 +31,7 @@ export const ControlButton = defineComponent({
},
setup(props, { slots }) {
return () => (
<button class={['react-flow__controls-button']} onClick={props.onClick} disabled={props.disabled}>
<button class={['react-flow__controls-button']} {...props}>
{slots.default ? slots.default() : ''}
</button>
);
@@ -85,23 +85,27 @@ const Controls = defineComponent({
setup(props, { slots }) {
const pinia = store();
const isVisible = ref<boolean>(false);
const { zoomIn, zoomOut, fitView } = useZoomPanHelper();
const zoomHelper = ref(useZoomPanHelper());
onMounted(() => {
zoomHelper.value = useZoomPanHelper();
});
const isInteractive = pinia.nodesDraggable && pinia.nodesConnectable && pinia.elementsSelectable;
const mapClasses = ['react-flow__controls'];
const onZoomInHandler = () => {
zoomIn?.();
zoomHelper.value.zoomIn?.();
props.onZoomIn?.();
};
const onZoomOutHandler = () => {
zoomOut?.();
zoomHelper.value.zoomOut?.();
props.onZoomOut?.();
};
const onFitViewHandler = () => {
fitView?.(props.fitViewParams);
zoomHelper.value.fitView?.(props.fitViewParams);
props.onFitView?.();
};