diff --git a/packages/controls/src/Controls.vue b/packages/controls/src/Controls.vue index 37bf5e37..00b76c44 100644 --- a/packages/controls/src/Controls.vue +++ b/packages/controls/src/Controls.vue @@ -23,10 +23,25 @@ const emit = defineEmits<{ (event: 'interactionChange', active: boolean): void }>() -const { nodesDraggable, nodesConnectable, elementsSelectable, setInteractive, zoomIn, zoomOut, fitView } = useVueFlow() +const { + nodesDraggable, + nodesConnectable, + elementsSelectable, + setInteractive, + zoomIn, + zoomOut, + fitView, + viewport, + minZoom, + maxZoom, +} = useVueFlow() const isInteractive = computed(() => nodesDraggable.value || nodesConnectable.value || elementsSelectable.value) +const minZoomReached = computed(() => viewport.value.zoom <= minZoom.value) + +const maxZoomReached = computed(() => viewport.value.zoom >= maxZoom.value) + function onZoomInHandler() { zoomIn() @@ -62,22 +77,25 @@ export default { diff --git a/packages/controls/src/style.css b/packages/controls/src/style.css index 1118bd43..73680286 100644 --- a/packages/controls/src/style.css +++ b/packages/controls/src/style.css @@ -26,3 +26,12 @@ .vue-flow__controls-button:hover { background: #f4f4f4; } + + +.vue-flow__controls-button:disabled { + pointer-events: none; +} + +.vue-flow__controls-button:disabled svg { + fill-opacity: 0.4; +}