← All Components
<mth-zoom-pan>
Accessible zoom and pan viewport with toolbar buttons, mouse wheel zoom, pointer pan, keyboard pan/zoom, and adopted CSSStyleSheet transforms.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-zoom-pan>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/zoom-pan"></script>
<mth-zoom-pan scale="1" min-scale="1">Example</mth-zoom-pan>import '@methane-ui/ui/zoom-pan';
import '@methane-ui/react';
export function Example() {
return <mth-zoom-pan scale="1" min-scale="1">Example</mth-zoom-pan>;
}<script setup lang="ts">
import '@methane-ui/ui/zoom-pan';
</script>
<template>
<mth-zoom-pan scale="1" min-scale="1">Example</mth-zoom-pan>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/zoom-pan';
import { MthZoomPanDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthZoomPanDirective],
template: `<mth-zoom-pan scale="1" min-scale="1">Example</mth-zoom-pan>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/zoom-pan';
import MthZoomPan from '@methane-ui/svelte/MthZoomPan.svelte';
</script>
<MthZoomPan scale="1" min-scale="1">Example</MthZoomPan>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
scale | scale | number | 1 | Current zoom multiplier. |
minScale | min-scale | number | 1 | Minimum allowed zoom scale. |
maxScale | max-scale | number | 4 | Maximum allowed zoom scale. |
step | step | number | 0.25 | Zoom scale increment per control/wheel step. |
panX | pan-x | number | 0 | Horizontal pan offset in pixels. |
panY | pan-y | number | 0 | Vertical pan offset in pixels. |
label | label | string | "" | Accessible region label. |
showControls | show-controls | boolean | true | Displays zoom-in, zoom-out, and reset toolbar buttons. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { scale: number; panX: number; panY: number } | Fired when scale or pan coordinates change. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| + / = | both | viewport focused | zooms in by step up to maxScale |
| - | both | viewport focused | zooms out by step down to minScale |
| 0 | both | viewport focused | resets zoom and pan offset |
| Arrow keys | both | zoomed and viewport focused | pans viewport offset (RTL-aware) |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 4 APG keyboard transitions across LTR/RTL. | mth-zoom-pan.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(zoomed). | Conformance suite |
| i18n | Routes 4 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |